From 4962f514e05ea7fc36280fa4127b5f22bf180894 Mon Sep 17 00:00:00 2001 From: copygirl Date: Fri, 16 Apr 2021 17:55:50 +0200 Subject: [PATCH] Fix "respawn" code when falling too low --- src/Player.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Player.cs b/src/Player.cs index 3738149..5bb03ba 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -40,17 +40,16 @@ public class Player : KinematicBody2D, IInitializer public override void _Process(float delta) { + if (Network.IsAuthoratative && (Position.y > 9000)) { + Position = Vector2.Zero; + if (this is LocalPlayer localPlayer) localPlayer.Velocity = Vector2.Zero; + else Network.API.SendTo(this, new PositionChangedPacket(this), TransferMode.Reliable); + } + if (Network.IsMultiplayerReady) { if (Network.IsServer) Network.API.SendToEveryoneExcept(this, new PositionChangedPacket(this)); else if (IsLocal) Network.API.SendToServer(new MovePacket(Position)); } - - if (Network.IsAuthoratative && (Position.y > 9000)) { - if (this is LocalPlayer localPlayer) { - localPlayer.Position = Vector2.Zero; - localPlayer.Velocity = Vector2.Zero; - } else Network.API.SendTo(this, new PositionChangedPacket(this)); - } }