#How do I rotate an object smoothly? And add to the rotation with each click

1 messages · Page 1 of 1 (latest)

real elk
#

Hello I want to rotate a disk with each button click, the problem is when I just use AddLocalRotation it instantly snaps to the new location. So I tried using a timeline but with a timeline it starts to infinitly spin. I tryed my timeline with the SetRelativeRotation instead of add and then it works, it smoothly changed the rotation. But set is only once and I want to change the rotation with each click a little bit more.

tender grail
#

Wire to Play from Start, not Play

But also, since it's "adding" local rotation, not "setting" local rotation, you don't need to lerp

#

You can just add a fixed amount each call (or delta time)

real elk
#

okay thanks i will try it out!

#

sadly it does not work
when i do it like this, or also with the lerp it still spins infinite
I want it to add a rotation everytime i click, everytime i click add +35 rotation but like this it does it all at once and it starts to spin super fast

tender grail
#

well you're adding 35 degrees every single tick

#

not in total

#

The Update output of a timeline is called every frame when the timeline progresses

#

Also forgive me I've not long woken up, the Lerp actually looked fine

#

I thought you wired up the wrong value. I need more coffee var

#

but

#

You shouldn't use Lerp with Add, it should be used with Set

#

So actual steps:

  1. Get the current rotation of the object, before starting the timeline. Store this value in a variable
  2. Timeline, keep the Lerp
  3. For A value of Lerp, have it be the stored rotation value. The starting rotation
  4. For B value, it should be start + desired delta (in your case 35)
  5. Use Set, not Add, rotation
real elk
#

yeah i dont really get behind timeline, i will watch a video about it
I will try solving it using your steps now

tender grail
#

So a timeline is just a way to transform values over time. I assume, in your case, you are increasing a single float from 0 to 1 since you have a float output

#

That's pretty much all they do. How you use that value is up to you

#

Like this

real elk
#

i did it like this now and it works! big thanks

tender grail
#

oh you could also lerp rotator yeah sure that works!

real elk
#

oh i forgot about the add operrator, but i think combine rotators works the same

tender grail
#

Actually, it arguably works better because you're storing the complete rotation

#

Whereas in my example, it's setting x and y to 0

#

you might want to keep x and y to their current values

#

So go with your solution LUL

#

Yeah, Combine Rotator with Lerp Rotator works much better

real elk
#

ok nvm its fine, my asset is just weird because its made out of combined parts