Odin for an arc, use a sin() function
sin(a)
this draws a curve that goes up and down. by scaling a
you can match the start and end of the curve to the position of the target.
another way is to just set a target
position or reference
an enemy, and rotate towards the target with the look_at()
function. for more complex behaviour you would need to calculate global_positions and vectors with looking_at()
. this code would be in the missile.
you can launch the missile to the side to start the curve, and set rotation speed to something small.
look_at
rotates the missile immediately towards the target.
looking_at
returns the rotation needed and can be slerp
ed to make it rotate slower.
#in 3D
const rotation_speed = 0.2
quaternion = quaternion.slerp(global_transform.looking_at(target.global_position - global_position).basis.get_rotation_quaternion(), rotation_speed)
another way is with a tween
.