# [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

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