added a coyote time for wall jumps
This commit is contained in:
@@ -25,7 +25,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
public MantleSystem MantleSystem;
|
||||
public DashSystem DashSystem;
|
||||
public CapsuleCollider CapsuleCollider;
|
||||
public TweenQueueSystem TweenQueueSystem;
|
||||
public Node3D WeaponRoot;
|
||||
public WeaponSystem WeaponSystem;
|
||||
public WallHugSystem WallHugSystem;
|
||||
@@ -205,10 +204,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _aimedDash;
|
||||
private StateChartState _onWall;
|
||||
private StateChartState _onWallHugging;
|
||||
private StateChartState _onWallHuggingCoyoteEnabled;
|
||||
private StateChartState _onWallHanging;
|
||||
private StateChartState _onWallRunning;
|
||||
private StateChartState _onWallRunningCoyoteEnabled;
|
||||
|
||||
private Transition _onJumpFromWall;
|
||||
private Transition _onJumpFromWall1;
|
||||
private Transition _onJumpFromWall2;
|
||||
private Transition _onJumpFromWall3;
|
||||
private Transition _onMegajumpFromWall;
|
||||
|
||||
private float _playerHeight;
|
||||
@@ -228,7 +231,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
|
||||
// General use stuff
|
||||
TweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
||||
PlayerUi = GetNode<PlayerUi>("UI");
|
||||
// DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
||||
PowerCooldownIndicator = GetNode<ColorRect>("%DashCooldownIndicator");
|
||||
@@ -290,12 +292,16 @@ public partial class PlayerController : CharacterBody3D
|
||||
_simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump"));
|
||||
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump"));
|
||||
_megaJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/MegaJump"));
|
||||
_onJumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnJump"));
|
||||
_onJumpFromWall1 = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/Hugging/OnJump"));
|
||||
_onJumpFromWall2 = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging/OnJump"));
|
||||
_onJumpFromWall3 = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/Running/OnJump"));
|
||||
_onMegajumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnMegajump"));
|
||||
_onWall = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall"));
|
||||
_onWallHuggingCoyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/HuggingCoyoteEnabled"));
|
||||
_onWallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hugging"));
|
||||
_onWallHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging"));
|
||||
_onWallRunning = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Running"));
|
||||
_onWallRunningCoyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/RunningCoyoteEnabled"));
|
||||
// State timers
|
||||
_powerCooldownTimer = GetNode<Timer>("PowerCooldown");
|
||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||
@@ -304,9 +310,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
// Initialize components //
|
||||
///////////////////////////
|
||||
|
||||
// General use stuff
|
||||
TweenQueueSystem.Init(this);
|
||||
|
||||
// Camera stuff
|
||||
HeadSystem.Init();
|
||||
@@ -318,7 +321,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_gravity = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
|
||||
MantleSystem.Init();
|
||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||
DashSystem.Init(HeadSystem, camera, TweenQueueSystem);
|
||||
DashSystem.Init(HeadSystem, camera);
|
||||
WeaponSystem.Init(HeadSystem, camera);
|
||||
WallHugSystem.Init();
|
||||
|
||||
@@ -373,11 +376,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
_onWall.StateEntered += OnWallStarted;
|
||||
_onWall.StateExited += OnWallStopped;
|
||||
_onWallHuggingCoyoteEnabled.StateEntered += OnWallHuggingStarted;
|
||||
_onWallHuggingCoyoteEnabled.StatePhysicsProcessing += HandleWallHugging;
|
||||
_onWallHugging.StatePhysicsProcessing += HandleWallHugging;
|
||||
_onWallHanging.StatePhysicsProcessing += HandleWallHanging;
|
||||
_onWallRunningCoyoteEnabled.StateEntered += OnWallRunningStarted;
|
||||
_onWallRunningCoyoteEnabled.StatePhysicsProcessing += HandleWallRunning;
|
||||
_onWallRunning.StatePhysicsProcessing += HandleWallRunning;
|
||||
|
||||
_onJumpFromWall.Taken += OnJumpFromWall;
|
||||
_onJumpFromWall1.Taken += OnJumpFromWall;
|
||||
_onJumpFromWall2.Taken += OnJumpFromWall;
|
||||
_onJumpFromWall3.Taken += OnJumpFromWall;
|
||||
_onMegajumpFromWall.Taken += OnMegajumpFromWall;
|
||||
}
|
||||
|
||||
@@ -470,7 +479,16 @@ public partial class PlayerController : CharacterBody3D
|
||||
// If all else fail and we go down, we hug
|
||||
if (Velocity.Y < 0 && !_coyoteEnabled.Active)
|
||||
_playerState.SendEvent("wall_hug");
|
||||
|
||||
}
|
||||
|
||||
public void OnWallHuggingStarted()
|
||||
{
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
}
|
||||
|
||||
public void OnWallRunningStarted()
|
||||
{
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
}
|
||||
|
||||
private Vector3 _wallHugStartLocation = Vector3.Zero;
|
||||
@@ -1111,7 +1129,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
var lookSensitivity = _isUsingGamepad ? _lookSensitivityMultiplier : _mouseSensitivityMultiplier;
|
||||
|
||||
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
|
||||
var wallHugContactPoint = _onWallRunning.Active || _onWallRunningCoyoteEnabled.Active ? _currentWallContactPoint : Vector3.Zero;
|
||||
var playerVelocity = GetGlobalMoveInput();
|
||||
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, wallHugContactPoint, lookSensitivity);
|
||||
}
|
||||
@@ -1191,7 +1209,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
||||
{
|
||||
Delta = delta,
|
||||
IsOnFloorCustom = isOnFloorCustom() || _onWallRunning.Active,
|
||||
IsOnFloorCustom = isOnFloorCustom() || _onWallRunning.Active || _onWallRunningCoyoteEnabled.Active,
|
||||
Velocity = Velocity,
|
||||
SettingsMultiplier = _headBobbingMultiplier
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user