Answer the question
In order to leave comments, you need to log in
How to limit the rotation of an object in Unity3d?
There is a 3d object (let's say a cube), using the code:
if (isRotate == true)
{
transform.Rotate(Vector3.down * speedRotate * Time.deltaTime);
}
if (isRotate == false)
{
transform.Rotate(Vector3.up * speedRotate * Time.deltaTime);
}
if (transform.rotation.y > -90)
{
transform.rotation = Quaternion.Euler(0, -90f, 0);
}
Answer the question
In order to leave comments, you need to log in
You can try to draw a line and count deviations from it. Another option is to take the standard value and count the deviations and in each frame determine the maximum deviation available (to the edges), but this is too much code for this. The first option is better.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question