mirror of
https://github.com/DerTyp7/TopDownShooter-Godot.git
synced 2025-10-29 21:02:13 +01:00
Fix collider and add waves
This commit is contained in:
19
Enemy.gd
19
Enemy.gd
@@ -4,6 +4,7 @@ var speed: float = 100.0
|
||||
var motion: Vector2 = Vector2.ZERO
|
||||
|
||||
func _ready():
|
||||
set_meta("dead", false)
|
||||
pass
|
||||
|
||||
func _physics_process(delta):
|
||||
@@ -11,12 +12,22 @@ func _physics_process(delta):
|
||||
var direction = (player.position - position).normalized()
|
||||
motion = direction * speed
|
||||
look_at(player.position)
|
||||
|
||||
|
||||
move_and_collide(motion * delta)
|
||||
|
||||
|
||||
func _on_area_2d_body_entered(body):
|
||||
#func _on_area_2d_body_entered(body):
|
||||
# print("Bullet hit")
|
||||
# print(body.name)
|
||||
# if "Bullet" in body.name:
|
||||
# set_meta("dead", true)
|
||||
# queue_free()
|
||||
|
||||
|
||||
func _on_area_2d_area_entered(area):
|
||||
print("Bullet hit")
|
||||
print(body.name)
|
||||
if "Bullet" in body.name:
|
||||
print(area.get_parent().name)
|
||||
if "Bullet" in area.get_parent().name:
|
||||
set_meta("dead", true)
|
||||
area.get_parent().queue_free()
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user