This repository has been archived on 2025-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
ld48/character/EnemyController.gd
2021-04-27 02:49:19 +02:00

20 lines
639 B
GDScript

extends Area2D
func _ready():
connect("body_entered", self, "on_body_entered")
connect("body_exited", self, "on_body_exited")
func on_body_entered(body):
if body.name == "PlayerCharacter":
get_tree().get_root().find_node("Game", true, false).set_music_track(Game.MusicTrack.COMBAT)
for child in get_children():
if child.has_method("set_target"):
child.set_target(body)
func on_body_exited(body):
if body.name == "PlayerCharacter":
get_tree().get_root().find_node("Game", true, false).set_music_track(Game.MusicTrack.EXPL)
for child in get_children():
if child.has_method("set_target"):
child.set_target(null)