Object rotation

I want to rotate an object via control input. I need to create a transform object and use that to define the target rotation so that I can use dt and a rotation speed to slew the rotation. My problem is how do I create the Transform object? I have tried many approaches none of which seem to work.

I need to do it this way because the manner in which rotate uses euler angles with signed degrees of rotation will not allow me to use a Vector3 to define the target rotation.

I wish there was an EulerAngle data type.

Is this not what you need? Transform.Rotate

  • You can express your target angles as a Vector3.
  • Subtract your current rotation Transform.eulerAngles to get the delta.
  • D a “wrap angle” on it so that your answer is ±180 degrees.
  • Clamp that to your maximum rotation speed.
  • Apply Transform.Rotate().

I’ve just answered what I suppose is a similar question: how to know the exact angle of some object after a rotation. You can’t trust in the values returned by eulerAngles after some rotation (it could return (0,180,0) or (180,0,180), for instance).

Take a look at this answer: