Animate a rotating object back to 0 from it's current rotation value

Hello

I have a cube that starts off static.
I then start rotating the cube using the Change Speed and Curve nodes.
At some point I would like to stop rotating the cube, but rather than it stop at some random rotation position, I would like it to rotate from it’s current rotation back to 0. This is so the cube is front facing again and is essentially “reset” back to what it was when it was static.

I was trying to capture the current rotation value with Allow First Value node, use that as the Set Position in the Smooth with Duration node and have Set Target as the end rotation of 0.

And toggle between an “on” and “off” state with a simple if else statement. However I can’t get it to animate back to 0. Does anyone have any ideas please? :pray:

Thanks!

Cube_Rotate.vuo (6.64 KB)

Hey ;)

Maybe I got caught in over complicated methods, and easier methods can be used, but joined are 3 comps.

1 - Version with Smooth With Duration

The problem here is that smooth with duration you set a duration for the animation (360°), but if you you’re at say 180, and you send back 0, it will take that same duration, but to go back from only 180 to 0, therefore it will be 2x slower for the spinning back animation.

2 - Version with Count Within Range

Seems a way to go too. However here there is no “Curve” (cubic, quadratic, exponential) to the animation, but only linear.

3 - Is a way to add curves to the 2nd method, but with Martinu’s custom node Time Curve link : here

But again, might be some way easier method I oversaw ;)  

Smooth With Duration.vuo (5.09 KB)

Count Within Range.vuo (4.98 KB)

Count Within Range With Time Curve.vuo (5.39 KB)

1 Like

Simpler: try replacing Allow First Value with Hold Value and might also need to fire an event to the target.

Screen Shot 2021-12-12 at 6.49.10 PM.png  

Thanks for the quick replies as always :)

@Bodysoulspirit the method Count Within Range achieves what I need as I don’t need easing in this instance. Nice to know about @MartinusMagneson node set though, have installed. I just added a multiply node so that the rotation continues in the same direction (rather than rotating in the opposite) to get back to the starting point.

@jersmi thanks! I learnt why it wasn’t working before, I had tried Hold Value but didn’t fire an event to Set Target. This method is not quite there yet, since I need it to start rotating from 0 again (I want to be able to start and stop the rotation repeatedly) so when I toggle back to “rotate” mode it is not at 0. I’m also not sure how to have it go back to 0 but in the same rotation direction like with the adjustment I made to Body’s file above.

Thanks again guys!  

2 Likes

Great it helped ;)
If you just want the animation to stop in the same spinning direction at the next 90° angle you can also do like in the joined comp, add 90° every time, but just don’t add another 90° when you want it to stop ;)
This way you’d still got an easing curve if you wanted to.

Cheers

 

Count & Smooth.vuo (5.4 KB)

4 Likes

This is bang on @Bodysoulspirit, love it!

1 Like