Smooth 90 degrees rotation

Hi, I am working on a project in which I need to rotate an object 90 degrees on the Y axis averytime I press a UI button. But I want the rotation to be smooth like not instantly rotate and we don’t see it rotate, I wanna see the rotation over X seconds. When I use the tween library, I can only rotate it once and then we I click back on the button it won’t rotate.

Anybody could help on that ?

Thanks a lot :slight_smile:

If you rotate it once and leave it in that position, it won’t rotate again since it has already been rotated to the “target” tween position.

Another way to do this would be to use the rotateLocal in the .update section of your script. Set a counter that gets updated with each dt cycle and then rotate the cube in the update section by a degree or two. I think dt is 1/60 of a second (not sure), so if you rotated one degree for ever dt update cycle you would rotate 90 degrees in 1.5 seconds.

Refer to this example on using the rotateLocal command:
https://developer.playcanvas.com/en/tutorials/keyboard-input/

Yeah, I thought it was bootleg, but it works and I love it ! Thanks for confirming that it was a good approach :smiley: