- Home /
How to lock rotation in z of my camera while rotating the camera by using mobile gyroscope input
I am rotating the camera in unity using gyroscope input, because I want the player to look around the x,y. However somehow there is also rotation in z. I've been slightly following this tutorial: youtube.com/watch?v=8ugE1HQPA9g. Am not using a camParent tough.
How do I keep the z rotation at 0, while keeping the same smooth rotation in x and y I have now?
Have been googling but haven't found any solutions which actually keep the z at 0. Here is the code I use for rotation, it's attached to the camera.
private void Start() { _rb = GetComponent(); Input.gyro.enabled = true; }
private void Update() { float gyro_In_x = -Input.gyro.rotationRateUnbiased.x; float gyro_In_y = -Input.gyro.rotationRateUnbiased.y;
transform.Rotate(gyro_In_x, gyro_In_y, 0);
}
Your answer
Follow this Question
Related Questions
Syncing Position and Rotation data in ECS tests? 0 Answers
How can I rotate my player with a Joystick? 0 Answers
Unity Asset Prefab Bug ThirdPersonController (left rotating bug / Snapping forward Always) 3 Answers
How can I rotate my gameobject around z-axis correctly? 0 Answers
Making an enemy fly towards Object and then around it until it's destroyed 1 Answer