I made a rotator that takes its value from a timeline to rotate an object:
A value of 5 in the timeline creates a rotation of 90 in the world. How does the scaling work here and why is it off?
I made a rotator that takes its value from a timeline to rotate an object:
A value of 5 in the timeline creates a rotation of 90 in the world. How does the scaling work here and why is it off?
This timeline is adding a relative rotation yaw on every frame, and the value that is added starts at 0 and ends at 5 degrees per frame after 1.2 seconds. This depends on the framerate as well, since the timeline calls the update function once every frame, so lower framerates will rotate the component less in total
Not sure what you want to do, but perhaps you should use set relative rotation and have the yaw values in a timeline curve - say you want to rotate the component from 0 to 90, then either have a curve going from 0 to 1 and use a lerp to define start and end values, or have the curve inside the timeline actually go from 0 to 90, and set the rotation like that
Otherwise, if you want a fixed rotation rate, you should just add relative rotation, but instead of taking the value from the timeline, just multiply your desired rotation rate with delta time and add that to the yaw. This way, if you want to rotate at a rate of 90 degrees per second, you can have a 1.2 second duration timeline, and add relative rotation yaw 90 * Delta time
, which should also make it framerate independent
How does the last method look in nodes? I can only find a node called “get delta time” and that has a blue context input. I don’t see how to use that.
It’s this node:
However, it will still not be perfect due to small float errors and frametime fluctuations which delta cannot account for perfectly. A timeline fires updates every frame, the more frames, the more updates, which equals to more or less rotation added.
Generally speaking, a Timeline
+ Add Rotation
is not a great combo tbh - unless you do have a very specific scenario and must use it this way, ofc. Or perfect rotation is not important.
If you wanted to rotate something 90 degrees over 1s, regardless of framerate, you’d Timeline
+ Lerp Rotator
and have the Timeline feed that latter node an alpha value in the range of 0-1.
Perhaps you could explain how the ideal end result looks like?
So I tried your suggested method and for some reason the value needs to be 7 to achieve a 90 degrees rotation, but it’s consistent now. I just don’t get the logic here.
The timeline has two points, one at 0 and one at 1 after 1.0 seconds, which should mean that after 1 second the rotation is 1x7?
The ideal result is a simple consistent rotation of 90 over 1 second which I’ve achieved. The reason I started the thread was because I couldn’t see the correlation between the inputs and the result.
a simple consistent rotation of 90 over 1 second
You’re using a wrong node for this behaviour - as mentioned above, do not combine Adding Rotation with a Timeline. The best case scenario will still be inconsistent - as soon as the frame-rate fluctuates, it will stop working.
Perhaps unrelated, but this would also allow you to easily parameterise the A & B rotators. However, It’s critical to set the data before the TL plays, and do not update / resample it during its Update
.
Good luck!
I get it now. The rotation was 180 by default which was what give unpredicted results. If I set to 0 by default and use Set Relative Rotation by 90 then it rotates by 90. Thanks.