Quantcast
Channel: Questions in topic: "rotating"
Viewing all articles
Browse latest Browse all 173

How can I rotate an object without moving it up or down?

$
0
0
This is my code there, i have an aircraft, it has a rigidbody component with no gravity(i have some constraints) the movement is good but when i try to rotate it left or right, it's rotating and increasing/decreasing its height. What can I do? public class Movement : MonoBehaviour { private Rigidbody rg; // Start is called before the first frame update void Start() { rg = GetComponent(); } // Update is called once per frame void Update() { rg.transform.Translate(Input.acceleration.x, 0, -Input.acceleration.z); rg.transform.Rotate(Vector3.back * Input.acceleration.x * 2f); } }

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>