Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Sprite
- onready var player_pos = get_parent().get_node("player").get_pos()
- var enemySpeed = 2
- func _ready():
- set_process(true)
- # Initialization here
- pass
- func _process(delta):
- var enemy_pos = get_pos()
- #
- #
- var dirx = player_pos.x - enemy_pos.x
- var diry = player_pos.y - enemy_pos.y
- # var dy = player_pos.y - get_pos().y
- #
- var hyp = sqrt(dirx * dirx + diry * diry)
- enemy_pos.x = enemy_pos.x + dirx / hyp * 2
- enemy_pos.y = enemy_pos.y + diry / hyp * 2
- set_pos(enemy_pos)
- print(enemy_pos.x )
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement