Is it possible to increase a float whenever the player tilts the device? I am trying to make a app where the player gets more score as he moves, but only if he is moving. I am using tilt controls for movement of the player.
I am using javascript.
Is it possible to increase a float whenever the player tilts the device? I am trying to make a app where the player gets more score as he moves, but only if he is moving. I am using tilt controls for movement of the player.
I am using javascript.
You could do something like:
var yourFloat : float = 0;
function Update ()
{
if (Input.deviceOrientation == DeviceOrientation.FaceDown)
{
yourFloat += 1;
}
}
If you’ve already implemented tilt controls for the player, you must have already learned about using Input.acceleration to get the accelerometer input: https://unity3d.com/learn/tutorials/modules/beginner/platform-specific/accelerometer-input
So all you need is an additional line in Update():
if(Input.acceleration.sqrMagnitude > 0) { score++; }