How to Script Object to Rotate Fixed Amount

Hello,

I’m sure there is a simple solution for this but I can’t seem to find anything online. Everything I find just shows how to script an object to rotate indefinitely. What I want is for the object to rotate only 270 degrees on just one axis and then stop. Whats the simplest way to accomplish this?

You can use timeline for that, this will allow you to control the look and ‘feel’ of rotation change too, using curves:

Timeline:

… You can also make it add to current object rotation like that:

By controlling the timeline curve you can also set rotation speed and other things.

Thanks! Quick question, for the “Progress” track did you create a new float track or new event track?

It’s a new float track, the first button.

Hi, i’m trying to put an object to rotate infinetly in a project in 1 axis (z). I used your script, but when i push play, nothing happens.
Can you help me understanding what i’m doing wrong?
Thanks
David Nogueira!

@danog07: the OP asked about rotating by a fixed amount - this is quite the opposite from your request “to rotate infinetly”. Perhaps all you need is a Rotating Movement Component.

It’s a fire & forget solution.

Thanks for the help. Spot on in what i needed. I just had to debug the mesh, because it was an import of a defective object, and the pivot point was all wrong.
Now it’s working. As it’s an object that in game will always rotate, it was thw right thing to do.
Thanks