Hello guys!
I'm creating a tank game and I'm having trouble rotating the enemy cannon towards the player. The direction has a 90 degree offset and I don't know what I'm doing wrong. Can you help me?
The code that i'm using:
var target_dir = (target.global_position - global_position).normalized()
print(target_dir)
var current_dir = Vector2(1,0).rotated($turrent.global_rotation)
$turrent.global_rotation = current_dir.linear_interpolate(target_dir, turrent_speed * delta).angle()
I've already tried to subtract 90 degrees but it doesn't work out.
Here's a gif to show you what's happening:
https://gph.is/g/Ev1GQ9z