GodotCourse/week5/original_project/scripts/gamecontroller.gd

19 lines
433 B
GDScript3
Raw Normal View History

extends Node2D
var crate = preload("res://scenes/crate.tscn")
@onready var boxtrap = $crates/boxtrap
func _on_area_2d_areatrigger(effect, body):
print("Game Controller sees the trigger "+effect)
match effect:
"alert":
#do stuff
print("hi")
if body.is_in_group("player"):
for n in 3:
var box = crate.instantiate()
add_child(box)
box.position = boxtrap.position
"powerup":
print("you got power")