The gyroscope sensor and how to use it

(updated 11 november 2016)

With the gyroscope sensor in the Pillos you can control the rotations over the X, Y and Z axes of a game object by simply tilting/rotating the Pillo. In order to retrieve the gyroscope values of a Pillo you need to use one of the GetGyro functions and read it out from a variable.


GetGyroX(PilloID); //Reads the gyroscope of the X axis.
GetGyroY(PilloID); //Reads the gyroscope of the Y axis.
GetGyroZ(PilloID); //Reads the gyroscope of the Z axis.

PilloID: the ID of the player to get the pressure of.

using UnityEngine;
using System.Collections;
using Pillo;

public class diceScript : MonoBehaviour 
	public PilloID pilloID;

	public float GyroX;
	public float GyroY;
	public float GyroZ;

	void Update () 
		GyroX = PilloController.GetGyroX(pilloID);
		GyroY = PilloController.GetGyroY(pilloID);
		GyroZ = PilloController.GetGyroZ(pilloID);
                print("GyroX: + GyroX);
                print("GyroY: + GyroY);
                print("GyroZ: + GyroZ);
                if(GyroZ > 0)
                     //Do something here.

If you would like to know how to use this function in a game, please take a look at this tutorial.