This helped me enormously on multiple projects already. Thanks, It's a really clever piece of code. However, do you know if there is a way to get rid of the stutter/vibration on "smooth" rotation when using a higher rotation speed?
what if I want to rotate a faced down 2d card and I want to reveal the hidden content and want to rotate like flipping it from left to right? is that possible?
Hi! What if i wanted my object to rotate (with the direct mode) only with 90° turns (without the upperleft, upperright, downleft and downright) ? I've been trying to mess around with the code but i can't really pull it out to work the way i want, thanks! edit: i am new to Godot beacause i usually used Unity engine but i'm trying to learn this engine :)
Hello, thanks for the comment 😊 The system you're describing is called stepping. GdScript has a built in method stepify(float a, float b) which snaps the float a with b amount of steps. for 90° snaps the code would look like this (direct mode): rotation_degrees.y = stepify(rad2deg(atan2(-direction.x, -direction.z)), 90) You can apply it in smooth mode too: var angle = stepify(atan2(-direction.x, -direction.z), deg2rad(90)) rotation.y = lerp_angle(rotation.y, angle, delta * SMOOTH_SPEED)
For whoever's guessing, 'smooth' goes like this:
rotation.y = lerp_angle(rotation.y, atan2(-direction.x, -direction.z), delta * SMOOTH_SPEED)
You have made my day!
thank you!
This is exactly what I needed! Thank you!
That smooth one looks amazing!
I have been struggling with this problem all day, and you gave me the perfect solution. THANK YOU!!
What solution where code?
This is amazing! Thanks for making the video!
Thank you. happy to help 😊
This helped me enormously on multiple projects already. Thanks, It's a really clever piece of code. However, do you know if there is a way to get rid of the stutter/vibration on "smooth" rotation when using a higher rotation speed?
Having this issue too. You ever solve it?
@@jaws8621 Unfortunately nope
@@jakubczajkowski407 Damn, thanks for getting back to me regardless.
thanks
what if I want to rotate a faced down 2d card and I want to reveal the hidden content and want to rotate like flipping it from left to right? is that possible?
Hi! What if i wanted my object to rotate (with the direct mode) only with 90° turns (without the upperleft, upperright, downleft and downright) ? I've been trying to mess around with the code but i can't really pull it out to work the way i want, thanks!
edit: i am new to Godot beacause i usually used Unity engine but i'm trying to learn this engine :)
Hello, thanks for the comment 😊 The system you're describing is called stepping. GdScript has a built in method stepify(float a, float b) which snaps the float a with b amount of steps. for 90° snaps the code would look like this (direct mode):
rotation_degrees.y = stepify(rad2deg(atan2(-direction.x, -direction.z)), 90)
You can apply it in smooth mode too:
var angle = stepify(atan2(-direction.x, -direction.z), deg2rad(90))
rotation.y = lerp_angle(rotation.y, angle, delta * SMOOTH_SPEED)
THX!