[Solved] Setting a rotation speed

after pressing a button
i can rotate an object around the x-axis by 30 degrees.
but this happens immediately.
now i want to SLOW down this movement by lets say 5 degrees per second within a smooth animation.
how can i do that?

Hi @designpeter this should work:

thanks for help.
just trying… but does not work. i keep on trying…
maybe it does not effect because its a 3D model?

maybe its my wrong explanation (sorry for my english). i try this explanation:

think of a motorbike, looking forward, standing straight: I

left arrow key is pressed =
i want to tilt it SLOWLY 30 degrees to the left: \

arrow key is released=
motorbike tilts slowly back to the straight position: I

right arrow key pressed=
i want to tilt it slowly 30 degrees to the right: /

hopefully this explanation helps ;-))

Yes, now I understand your question better! Try this instead:

The last number “0.025” controls the speed of the rotation. Higher = faster, lower = slower, but keep it between 0-1.

Hope this works as you want it!

#insein
thanks for your patience :wink:

2 questions:

  1. lets say the 3d-model name is “Bike”
    what is the correct syntax in the action ?
    (bit confused because of object.Object3D)
  2. this is displayed when i played around with this function
    “This behavior is not attached to this object”
    (what behavior has to be attached to the 3-d-model?)

The “Object3D::RotationX()” just gets the angle of rotation on the x-axis no behavior is attached to the 3d model, maybe there’s a typo?

The syntax would be: lerp(Bike.Object3D::RotationX(), 30, 0.025)

1 Like

tried, but does not work.
Object3D:
(is underlined in red…this bahavior is not attached to the object…)

oh, maybe its because of:
the 3d model is a .glb model (Bike.glb)
?

hurra/2

yes, it works now with
lerp(Bike.RotationX(), 30, 0.025)
in the DOWN direction from 0 to 30 degrees

but it does not work after “key was released” or “key is not pressed”.
the object tilts back immediately from 30 to 0 with no smooth movement.
…
why ?

Now it works. (had a typo issue…)
lerp(Bike.RotationX(), 30, 0.025)
thanks to the help of #insein

1 Like

No problem I’m happy to help.

Weird! It worked when I tried it in my example. I’m glad you managed to make it work in the end :slight_smile: