Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rollAngle = Mathf.Atan2(transform.up.x, transform.up.y);
- var pitchAngle = Mathf.Atan2(transform.up.z, transform.up.y);
- var h = Input.GetAxis ("Horizontal");
- var v = Input.GetAxis ("Vertical");
- if (h == 0 && v == 0)
- {
- // auto level
- h = -rollAngle / 90f;
- v = -pitchAngle / 90f;
- }
- rigidbody.AddRelativeTorque (Vector3(1, 0, 0) * v *0.005);
- rigidbody.AddRelativeTorque (Vector3(0, 0, 1) * h *-0.005);
Advertisement
Add Comment
Please, Sign In to add comment