Home Unreal Engine

[Blueprint] Smooth object rotation with Timeline node

polycounter lvl 8
Offline / Send Message
mickeyvpn polycounter lvl 8
Hey guys,

I'm trying to make a blueprint in Unreal Engine for asset presentation. Idea in general is to make circular array of assets that will rotate to take place before the camera when player press key/mouse click.
I've started with simple script for spawning static meshes around circle with even distance between each. Then I made a function(RotateForward Function) which rotate SceneRoot for an angle based on distance between meshes. It working well, but rotation is instant.


Then I wanted to make this rotation to be smooth with help of Timeline node. And here things goes crazy.  Blueprint begin spinning like hell with unknown logic for me.


Can you guys suggest something to setup blueprint with Timeline node properly or maybe there are some different ways to archive smooth object transition?

Here is Blueprint on blueprintue.com
Construction script
Event Graph
RotateForward Function

Thank you.

Replies

  • WitchDev
    Offline / Send Message
    WitchDev node
    Your construction script is fine, but your rotation is speeding up because your timeline goes from zero to one and therefore adds a larger rotation every single frame.
    You need to calculate a delta from the rotation in the last step instead and add that to your current rotation. (timeline should start at zero and end at one, you can even make it go past one  before the end to create a bit of a bounce effect but at the very end of the timeline the value should be one).

  • mickeyvpn
    Offline / Send Message
    mickeyvpn polycounter lvl 8
    Hello @WitchDev

    Thank you for your help, it's working as I wanted to!

    Can you help me with explanation on this piece inside Event Graph

    If I understand it right, this is the place where we get our delta from last rotation. But I thought that value that came from Rotation output in Timeline node is always between 0 to 1. But now it turns out that this Rotation output gives us the whole rotation angle or I'm missing something?
  • WitchDev
    Offline / Send Message
    WitchDev node
    I'll make an example that hopefully clarifies what is happening:
    For simplicity, your timeline is linear going from zero to one in one second.
    Let's assume you have 4 frames per second, the rotation values you get from your timeline will be: 0.25, 0.5, 0.75 and 1.0 add them all together and you get a total of 2.5.
    Let's assume you have 10 fps, now the rotation values your timeline gives you will be: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 and 1.0, the sum of these values is 5.5.
    You end up with different values depending on your fps, but if you calculate the delta you'd get for 4 fps a value of 0.25 each step and for 10 fps 0.1 each step which both add up to 1.0 which is the value you want for your rotation.
    (Btw the reason why your objects start spinning in place in your gif is probably because you didn't reduce the "length" of your timeline which kept giving a rotation value of 1 for a few more seconds, the length value is on the bar at the top of your timeline graph and really easy to miss.)

    Here is an alternative solution without a delta value, maybe this helps you understand this better (or it just creates more confusion, difficult to tell with these things).


  • mickeyvpn
    Offline / Send Message
    mickeyvpn polycounter lvl 8
    @WitchDev

    Thank you very much, now it have more sense to me.
    Is there a way to check what FPS value is actually used in Timeline node. I mean we can define length in seconds but can we increase or decrease amount of frames that will be in that node?
  • WitchDev
    Offline / Send Message
    WitchDev node
    I don't think you can, the FPS is just whatever fps the game is running with and will always vary to some extent. Unreal Engine is designed such that a wide range of framerates is supported and a game can run fine whether it runs at 30fps or 300fps.
  • mickeyvpn
    Offline / Send Message
    mickeyvpn polycounter lvl 8
    @WitchDev

    Thank you so much.
    Can you please explain one more thing. I'm watching values that go to Delta rotation input. After each time in the end of animation value is random, doesn't it meant to be constant?



  • WitchDev
    Offline / Send Message
    WitchDev node
    The value is random because your frame rate varies each time you run it and the large difference at the end depends just on how close the second to last tick was to the end time of the timeline.
    the timeline runs for 1 second, you have roughly 10 fps. One time you could have a frame 0.91 seconds after the start of the timeline and the next frame sometime after the end of it, your delta will be 0.09, if your last frame before the end would have been at 0.98 seconds after the timeline was started the last delta will end up being 0.02. (I'm pretty sure that's how unreal handles this situation)

  • mickeyvpn
    Offline / Send Message
    mickeyvpn polycounter lvl 8
    Wow, that makes sense. Thank you for your help :)
Sign In or Register to comment.