Say that I have square and I have to rotate it every frame (or physics update) to 90 degrees on the z axis all in a fixed time (1 second). How do I do it?
public Transform target;
public float speed = 1.0f;
void Update()
{
Vector3 targetDirection = target.position - transform.position;
float singleStep = speed * Time.deltaTime;
Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);
transform.rotation = Quaternion.LookRotation(newDirection);
}
Look this script, it can be useful to animating the rotation per second.