diff --git a/Shared/Behaviours/Paddle.cs b/Shared/Behaviours/Paddle.cs index f912ba3..0e5f735 100644 --- a/Shared/Behaviours/Paddle.cs +++ b/Shared/Behaviours/Paddle.cs @@ -88,16 +88,19 @@ public class Paddle(Keys Up, Keys Down, float High, float Low, float Speed) : Be public void OnClientPacketArrived(IConnection sender, PaddleKeyStatePacket packet) { + if (packet.IsDownPressed || packet.IsUpPressed) // Check if the server paddle is moving + if (isDownPressed == packet.IsDownPressed && isUpPressed == packet.IsUpPressed) // Check if we are the ones giving the inputs + return; + + physicsEngine2D.StepIndividual(rigidBody, -sender.Ping); + isUpPressed = packet.IsUpPressed; isDownPressed = packet.IsDownPressed; - Vector2D localToServerPosition = Transform.Position.FromTo(packet.Position); - if (localToServerPosition.MagnitudeSquared < 1f) - networkTween = Transform.TweenPositionAdditive(tweenManager, .25f, localToServerPosition); - else - Transform.Position = packet.Position; - physicsEngine2D.StepIndividual(rigidBody, sender.Ping); + + Vector2D localToServerPosition = Transform.Position.FromTo(packet.Position); + networkTween = Transform.TweenPositionAdditive(tweenManager, .1f, localToServerPosition); } public class PaddleKeyStatePacket : IEntityNetworkPacket