![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | javrocks |
How would u do this with code??
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | javrocks |
How would u do this with code??
![]() |
Reply From: | grognard3 |
Um, I guess very generally you could adapt something like:
var enemypos = Vector2( #, # )
var playerpos = Vector2( #, # )
var movement = Vector2( #, # )
func _process(delta):
if enemypos.x > playerpos.x:
movement.x = 1
else:
movement.x = -1
if enemypos.y > playerpos.y:
movement.y = 1
else:
movement.y = -1
enemy.set_position(movement)
Ok thanks i’ll try it
javrocks | 2021-06-27 15:50