2.11 crashing and respawning
This commit is contained in:
parent
c311181e8b
commit
1438dc7784
2 changed files with 18 additions and 2 deletions
7
general/utils.cs
Normal file
7
general/utils.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
static class DeferredCalls {
|
||||||
|
public static void ReloadCurrentScene(this Node node) {
|
||||||
|
node.GetTree().CallDeferred("reload_current_scene");
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,11 +34,20 @@ public partial class Player : RigidBody3D
|
||||||
{
|
{
|
||||||
if (body.GetGroups().Contains("Goal"))
|
if (body.GetGroups().Contains("Goal"))
|
||||||
{
|
{
|
||||||
GD.Print("Player landed on the landing pad");
|
CompleteLevel();
|
||||||
}
|
}
|
||||||
if (body.GetGroups().Contains("Hazard"))
|
if (body.GetGroups().Contains("Hazard"))
|
||||||
{
|
{
|
||||||
GD.Print("Player crashed on the floor :(");
|
CrashSequence();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CrashSequence(){
|
||||||
|
GD.Print("Player crashed on the floor :(");
|
||||||
|
DeferredCalls.ReloadCurrentScene(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompleteLevel(){
|
||||||
|
GetTree().Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue