Quantcast
Channel: Questions in topic: "weight"
Viewing all articles
Browse latest Browse all 136

How to rotate a rigidbody with limited angles and physics?

$
0
0
I need to rotate an object through input but limit the rotation angle. Also I need to put some weight at every corner of the plane and make it affect the plane's rotation. Right now I can only rotate the plane with limited angles without physics. Here's the code; void Update() { if (Input.GetKey("up")) { curAngle.x += rotSpeed * Time.deltaTime; } if (Input.GetKey("down")) { curAngle.x -= rotSpeed * Time.deltaTime; } if (Input.GetKey("left")) { curAngle.z += rotSpeed * Time.deltaTime; } if (Input.GetKey("right")) { curAngle.z -= rotSpeed * Time.deltaTime; } curAngle.x = Mathf.Clamp(curAngle.x, -15, 15); curAngle.z = Mathf.Clamp(curAngle.z, -15, 15); transform.eulerAngles = initialAngles + curAngle; } I need to change this so I can move it adding force to simulate this "weight control" effect. Thanks for the attention in advance.

Viewing all articles
Browse latest Browse all 136

Trending Articles



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