Smooth Rotation to a Specific Angle

Problems Koding something? Get help from other users here!
User avatar
LucidStew
Level 3
Level 3
Posts: 178

Smooth Rotation to a Specific Angle

Post#1 » Fri Aug 19, 2016 6:52 am

This one is mine...

This topic has been brought up many times, and the solution never seemed all that simple. I stumbled upon something interesting while fiddling with my jetpack controls.

if you set [up] to [world up] every frame:

w: d: [up][=][world up]

and set a roll to certain number every frame:

w: d: [roll][45]

your object will be tilted at that angle. In this case 45 degrees. So for smooth rotation what I did was:

w: d: [up][=][world up]
w: input1 d: [#X][increment by][#Y]
w: input2 d: [#X][decrement by][#Y]
w: d: [#X][=][clamp][#X][max][#Z][min][-#Z]
w: d: [roll][#X]

This will cause the object to roll from -#Z angle to #Z angle at a rate of #Y degrees per frame with the required input. You can also have it right itself with something like this:

w: [not]input1[and][not]input2 d:
>w: [#X][greater than equal to][#Y] d: [#X][decrement by][#Y]
>w: [#X][less than equal to][#Y] d: [#X][increment by][#Y]
End of line.

Return to “Koding Konversations”

Who is online

Users browsing this forum: No registered users and 1 guest

cron