-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEnemy.gd
More file actions
33 lines (21 loc) · 690 Bytes
/
Enemy.gd
File metadata and controls
33 lines (21 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extends KinematicBody2D
# Called when the node enters the scene tree for the first time.
var motion = Vector2()
var speed = 3
func _ready():
pass # Replace with function body.
func _physics_process(delta):
var motion = Vector2()
var Player = get_parent().get_node("player")
motion += (Vector2(Player.position) - position)
look_at(Player.position)
motion = motion.normalized() * speed
move_and_collide(motion)
#func _physics_process(delta):
# var Player = get_parent().get_node("player")
# position += (Player.position - position)/50
# look_at(Player.position)
# move_and_collide(motion)
func _on_Area2D_body_entered(body):
if "Bullet" in body.name:
queue_free()