#Turret needs to aim at mouse cursor while maintaining constant limited speed
1 messages · Page 1 of 1 (latest)
This is the most effective method I've found but it flips direction (and goes all the way around) when going from 360 to 0
if abs(difference) < SPEED * delta:
rotation = rotation_angle
else:
rotation += signf(difference) * SPEED * delta ```
lerp does not have a constant movement value, and just following the mouse does not have the delay or movement speed limit I am looking for.
Pls help :<
The dot product might help you determine whether to turn right or left.
https://docs.godotengine.org/en/stable/tutorials/math/vector_math.html#facing
In the example, they use it to determine in front or behind, but it works the same for left and right. Use the character's y basis vector instead of their x-vector.
Introduction: This tutorial is a short and practical introduction to linear algebra as it applies to game development. Linear algebra is the study of vectors and their uses. Vectors have many appli...
Godot has a helper function, I think it's called angle_difference, which you should use instead of plain minus
Heres the updated functional code for anyone in the future with a similar issue