system
October 15, 2022, 11:48pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
Undorobo
This code is for turrets to aim at the enemy
func _process(delta):
var dist = global_position.distance_to(enemy.global_position)
look_at(enemy.global_position + enemy.enemy_vol * (dist/10))
but I don’t want the turrets’ sprite to rotate with it.
system
October 16, 2022, 2:39am
2
Reply From:
love_this_name
You can get the unit vector that points towards a target like this:
var direction = ( target.get_pos() - self.get_pos() ).normalized()
credit to @YeOldeDM from this post
Thanks, it works nicely!
Can direction_to() also be used for this? If so, how does it look like? I got “nonexistent function” when I tried it before which is likely caused by wrong syntax.
Undorobo | 2022-10-16 09:57