public override void _PhysicsProcess(float Delta) { if (!Possessed) { return; } if (ForwardAxis == 0 && IsOnFloor()) { if (Momentum.z > 0) { Momentum.z = Mathf.Clamp(Momentum.z - Friction * Delta, 0f, MaxMovementSpeed); } else if (Momentum.z < 0) { Momentum.z = Mathf.Clamp(Momentum.z + Friction * Delta, -MaxMovementSpeed, 0f); } } if (RightAxis == 0 && IsOnFloor()) { if (Momentum.x > 0) { Momentum.x = Mathf.Clamp(Momentum.x - Friction * Delta, 0f, MaxMovementSpeed); } else if (Momentum.x < 0) { Momentum.x = Mathf.Clamp(Momentum.x + Friction * Delta, -MaxMovementSpeed, 0f); } } if (IsJumping && JumpTimer <= MaxJumpLength) { JumpTimer += Delta; Momentum.y = Mathf.Clamp(Momentum.y + JumpContinueForce * Delta, -MaxMovementSpeed, MaxMovementSpeed); } else { JumpTimer = 0f; IsJumping = false; Momentum.y = Mathf.Clamp(Momentum.y - Gravity * Delta, -MaxMovementSpeed, MaxMovementSpeed); } Vector3 OldPos = Translation; MoveAndSlide(Momentum.Rotated(new Vector3(0, 1, 0), Mathf.Deg2Rad(LookHorizontal)), new Vector3(0, 1, 0), 0.05f, 4); //MoveAndSlide multiplies by *physics* delta internally Vector3 NewPos = Translation; Translation = OldPos; if (NewPos != OldPos) { Perform.LocalPlayerMove(Events.INVOKER.CLIENT, NewPos); } if (IsOnFloor() && Momentum.y <= 0f) { Momentum.y = -1f; } Message.PlayerRequestPos(Translation); Message.PlayerRequestRot(RotationDegrees.y); }