gd: some weapon planting and dashing

This commit is contained in:
2025-06-07 17:42:39 +02:00
parent 82cc25ddd3
commit 55f036f725
6 changed files with 145 additions and 15 deletions

View File

@ -18,7 +18,8 @@ public partial class MoveSystem : Node3D
Vector3 MovementDirection,
bool IsOnFloor,
bool IsDead,
bool IsHeadTouchingCeiling
bool IsHeadTouchingCeiling,
bool isHanging
);
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
@ -30,14 +31,14 @@ public partial class MoveSystem : Node3D
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
public float _currentSpeed;
private const float DecelerationSpeedFactorFloor = 15.0f;
private const float DecelerationSpeedFactorAir = 7.0f;
private const float DecelerationSpeedFactorFloor = 5.0f;
private const float DecelerationSpeedFactorAir = 1.0f;
public float CrouchTransitionSpeed { get; set; } = 20.0f;
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
public float DoubleJumpSpeedFactor { get; set; } = 2f;
private bool _canDoubleJump = true;
public bool CanDoubleJump { get; set; } = true;
private float _lastFrameWasOnFloor = -Mathf.Inf;
private Gravity _gravity;
@ -60,10 +61,17 @@ public partial class MoveSystem : Node3D
public void MoveAround(MoveAroundParameters param)
{
var (delta, movementDirection, isOnFloor, isDead, isHeadTouchingCeiling) = param;
var (delta, movementDirection, isOnFloor, isDead, isHeadTouchingCeiling, isHanging) = param;
var doesCapsuleHaveCrouchingHeight = _capsuleCollider.IsCrouchingHeight();
var doesCapsuleHaveDefaultHeight = _capsuleCollider.IsDefaultHeight();
if (isHanging)
{
_parent.Velocity = Vector3.Zero;
_parent.MoveAndSlide();
return;
}
// Adding the gravity
if (!isOnFloor)
@ -77,7 +85,7 @@ public partial class MoveSystem : Node3D
if (isOnFloor)
{
_lastFrameWasOnFloor = Engine.GetPhysicsFrames();
_canDoubleJump = true;
CanDoubleJump = true;
}
// The code below is required to quickly adjust player's position on Y-axis when there's a ceiling on the
@ -181,9 +189,9 @@ public partial class MoveSystem : Node3D
y: _gravity.CalculateJumpForce(),
z: _parent.Velocity.Z);
}
else if (_canDoubleJump)
else if (CanDoubleJump)
{
_canDoubleJump = false;
CanDoubleJump = false;
_parent.Velocity = new Vector3(
x: _parent.Velocity.X,
y: _gravity.CalculateJumpForce() * DoubleJumpSpeedFactor,