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.