Make character move up on Y axis as apposed to move forward in Z space when mobile device is tilted
I have a character floating in outer space that is being controlled by the gyroscope, it moves accurately with what code I have so far. Though I would like the character to move up on the screen and not farther away from camera by moving in Z space, since all action is taking place in one spot. Its going to be on IOS and heres what I have so far:
void Update() { transform.Translate (Input.acceleration.x, 0, -Input.acceleration.z);
}
Answer by hexagonius · Mar 21, 2017 at 09:57 PM
exchange the y parameter 0 with the z parameter Input.acceleration.z
Answer by jigwiz · Mar 23, 2017 at 12:16 AM
After very little research this seems to do what I want:
void Update ()
{
transform.position += Vector3.forward * Time.deltaTime;
}
}
I guess now Im going to attempt to add different random rotation values to the objects themselves
Your answer
Follow this Question
Related Questions
How do I adjust code so gyro translates player to center position when device is being held in hands 1 Answer
Im trying to make a player move 360 degree gyroscopic movement on my phone 0 Answers
How do you reduce jittering for gyroscope control system? 0 Answers