-
Senior Member
Math stuff
hey guys,
i want to rotate a object with the values from the right stick.
how can i convert the vertical -3 to +3 and horizontal -3 to +3 values into a range from 0 to 359?

it looks so easy on the picture but i cant get my head around it
thanks!
-
Trials Developer
With arctan2:
-
Senior Member
hey mutetus,
no its not gonna work like that. if the horizontal value is > 0 i get values from 0 to +180 and if its < 0 i get values from 0 to -180.
anyway now i got it to work, maybe more complicated than it has to be (?) but it works
thanks for your help!
but now i got another question
if i interpolate the angle value, to get a smoother transition, the animation is like bouncing. any idea how to avoid that?
hard to explain, here is a short vid:
-
Trials Developer
Ok then does this help?
The bottom right variable datasource has the interpolation settings, it just takes the value from the normal variable datasource.
-
Senior Member
hahaha whaaaaaat is this?
it works perfect but i dont get it what you did there.
im sure it has something to do with the impulse delay of 0,0166666666666667 so that i cant even see whats happening on the screen. can you try to explain how this works exactly?
thanks <3
-
Trials Developer
It's hard to explain my stuff
Basically instead of taking the angle straight from the arctan2, the angle difference between the previous and current tick is calculated and added to variable that doesn't wrap around 360. The trick is in the angle difference+540 mod 360 - 180 part in the middle, which corrects the value when it wraps around 360. After setting the angle in the datasource the current angle is stored to the other datasource for next tick comparison.
-
Senior Member
AAAAAHHH! This is exactly what I needed for something else
!
I was trying to rotate the rider using ArcTan2 smoothly but yeah, once he hit 360 degrees, he spun around in the opposite direction :P.