- Home /
Not sure if you can do this..
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.
Answer by tanoshimi · Jun 08, 2015 at 05:24 AM
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++; }
Answer by Calum1015 · Jun 08, 2015 at 03:26 AM
You could do something like: var yourFloat : float = 0;
function Update ()
{
if (Input.deviceOrientation == DeviceOrientation.FaceDown)
{
yourFloat += 1;
}
}
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
How to properly send data over TcpClient? 0 Answers
Collide script not working... 1 Answer
ren]er cube problem 0 Answers