Smoothing rotation when following navigation path.
I have an ememy that uses navmesh for path finding. I want the emey to face the direction of the next path position.
everything seem to go wrong when the rotation loops round it results in the enemy spinning quickly in the opposite direction until hes facing the correct way.
var smooth_angle var direction = global_position.angle_to_point(path) var distance = position.distance_to(path) if distance > 100: position = position.linear_interpolate(path, (speed * delta) / distance) smooth_angle = lerp(rotation, direction, delta * 6.0) print(smooth_angle) rotation = smooth_angle
when printing the angle the ranges seem to go from -3 to +3 the spinning occurs when i rotate past +3 to -3 and vice versa.
very new to this any help pointing me in the right direction would be appreciated.