gd: simple mantle
This commit is contained in:
@ -123,8 +123,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
MantleSystem.CheckWallInFront();
|
||||
|
||||
var mantleLocationResult = MantleSystem.CheckWallInFront();
|
||||
if (isOnFloorCustom())
|
||||
{
|
||||
_lastFrameWasOnFloor = Engine.GetPhysicsFrames();
|
||||
@ -145,24 +144,33 @@ public partial class PlayerController : CharacterBody3D
|
||||
bool isPlayerDead = HealthSystem.IsDead();
|
||||
|
||||
// Handle Jumping
|
||||
if (Input.IsActionJustPressed("jump") && isOnFloorCustom()
|
||||
&& !doesCapsuleHaveCrouchingHeight && !isPlayerDead)
|
||||
if (Input.IsActionJustPressed("jump")
|
||||
&& !doesCapsuleHaveCrouchingHeight
|
||||
&& !isPlayerDead)
|
||||
{
|
||||
Velocity = new Vector3(
|
||||
x: Velocity.X,
|
||||
y: Gravity.CalculateJumpForce() * (float)delta,
|
||||
z: Velocity.Z);
|
||||
}
|
||||
else if (Input.IsActionJustPressed("jump") && !isOnFloorCustom()
|
||||
&& !doesCapsuleHaveCrouchingHeight && !isPlayerDead && _canDoubleJump)
|
||||
{
|
||||
_canDoubleJump = false;
|
||||
Velocity = new Vector3(
|
||||
x: Velocity.X,
|
||||
y: Gravity.CalculateJumpForce() * (float)delta * DoubleJumpSpeedFactor,
|
||||
z: Velocity.Z);
|
||||
if (mantleLocationResult.IsOk(out var mantleLocation))
|
||||
{
|
||||
Position = mantleLocation;
|
||||
}
|
||||
else if (isOnFloorCustom())
|
||||
{
|
||||
Velocity = new Vector3(
|
||||
x: Velocity.X,
|
||||
y: Gravity.CalculateJumpForce() * (float)delta,
|
||||
z: Velocity.Z);
|
||||
}
|
||||
else if (!isOnFloorCustom()
|
||||
&& _canDoubleJump)
|
||||
{
|
||||
_canDoubleJump = false;
|
||||
Velocity = new Vector3(
|
||||
x: Velocity.X,
|
||||
y: Gravity.CalculateJumpForce() * (float)delta * DoubleJumpSpeedFactor,
|
||||
z: Velocity.Z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
||||
bool doesCapsuleHaveDefaultHeight = CapsuleCollider.IsDefaultHeight();
|
||||
|
||||
|
Reference in New Issue
Block a user