From d3f6967fe666595cf0862be57a3dae3bb23afd24 Mon Sep 17 00:00:00 2001 From: IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> Date: Sun, 17 Jul 2022 03:40:41 +0200 Subject: asset for the goal trigger --- godot/scenes/objects/GoalTriggerBox.gd | 22 ++++++++++++++++++++++ godot/scenes/objects/GoalZone.tscn | 13 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 godot/scenes/objects/GoalTriggerBox.gd create mode 100644 godot/scenes/objects/GoalZone.tscn (limited to 'godot/scenes/objects') diff --git a/godot/scenes/objects/GoalTriggerBox.gd b/godot/scenes/objects/GoalTriggerBox.gd new file mode 100644 index 0000000..9659520 --- /dev/null +++ b/godot/scenes/objects/GoalTriggerBox.gd @@ -0,0 +1,22 @@ +extends Area + +const Loader = preload("res://scenes/Game.gd") +var loader: Loader = null + +# Called when the node enters the scene tree for the first time. +func _ready(): + loader = get_node("/root/Game") + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_Area_body_entered(body: RigidBody): + # return when body is not a rigidbody + if body == null: + return + + loader.end_level() + diff --git a/godot/scenes/objects/GoalZone.tscn b/godot/scenes/objects/GoalZone.tscn new file mode 100644 index 0000000..79b8624 --- /dev/null +++ b/godot/scenes/objects/GoalZone.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://scenes/objects/GoalTriggerBox.gd" type="Script" id=1] + +[sub_resource type="BoxShape" id=1] + +[node name="GoalZone" type="Area"] +script = ExtResource( 1 ) + +[node name="CollisionShape" type="CollisionShape" parent="."] +shape = SubResource( 1 ) + +[connection signal="body_entered" from="." to="." method="_on_Area_body_entered"] -- cgit