Here is my code:
public class test : MonoBehaviour
{
[SerializeField] [Range(0f, 5f)] float rotationSpeed;
public float z_Z = 0;
public bool rotating = false;
private void Rotate()
{
//rotZ += Time.deltaTime * rotationSpeed;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0,0,z_Z),rotationSpeed*Time.deltaTime);
if (transform.rotation == Quaternion.Euler(0, 0, z_Z))
{
Debug.Log(transform.rotation);
rotating = false;
}
//transform.rotation = Quaternion.Euler(0, 0, rotZ);
}
private void Update()
{
if (rotating == false)
{
if (Input.GetKeyDown(KeyCode.A))
{
z_Z += 90f;
if (z_Z > 360)
{
z_Z = 90;
}
rotating = true;
}
if (Input.GetKeyDown(KeyCode.D))
{
z_Z -= 90f;
if (z_Z < -360)
{
z_Z = -90;
}
rotating = true;
}
}
if (rotating == true)
{
Rotate();
}
}
}
After i make a full rotation on my object and + 90 degree (im pressing five times "A" or "D")
Rotating stays "true" but in inspector the transform.rotation and Quaternion.Euler is equal:
![alt text][2]
[2]: https://i.imgur.com/utYL89w.png
↧