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);
}
}
↧