buffered inputs revamped and added mantle jumps and dashed
This commit is contained in:
@@ -67,6 +67,8 @@ AccelerationAir = 0.8
|
|||||||
DecelerationAir = 0.02
|
DecelerationAir = 0.02
|
||||||
Weight = 4.0
|
Weight = 4.0
|
||||||
MantlePath = ExtResource("2_6lejt")
|
MantlePath = ExtResource("2_6lejt")
|
||||||
|
MantleDashStrength = 20.0
|
||||||
|
MantleJumpStartVelocity = 13.0
|
||||||
CoyoteTime = 0.3
|
CoyoteTime = 0.3
|
||||||
InputBufferFrames = 5
|
InputBufferFrames = 5
|
||||||
SimpleJumpStartVelocity = 6.0
|
SimpleJumpStartVelocity = 6.0
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
private bool _isUsingGamepad;
|
private bool _isUsingGamepad;
|
||||||
|
|
||||||
|
public enum BufferedActions
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Jump,
|
||||||
|
MantleJump,
|
||||||
|
Dash,
|
||||||
|
MantleDash
|
||||||
|
}
|
||||||
|
private BufferedActions _bufferedAction = BufferedActions.None;
|
||||||
|
|
||||||
// User API to important child nodes.
|
// User API to important child nodes.
|
||||||
public HeadSystem HeadSystem;
|
public HeadSystem HeadSystem;
|
||||||
public Bobbing Bobbing;
|
public Bobbing Bobbing;
|
||||||
@@ -79,12 +89,19 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
public float DecelerationAir = 1.0f;
|
public float DecelerationAir = 1.0f;
|
||||||
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
||||||
public float Weight { get; set; } = 3.0f;
|
public float Weight { get; set; } = 3.0f;
|
||||||
|
|
||||||
|
// Mantle
|
||||||
[ExportGroup("Mantle")]
|
[ExportGroup("Mantle")]
|
||||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
public float MantleTime { get; set; } = 0.1f;
|
public float MantleTime { get; set; } = 0.1f;
|
||||||
[Export]
|
[Export]
|
||||||
public PackedScene MantlePath { get; set; }
|
public PackedScene MantlePath { get; set; }
|
||||||
|
|
||||||
|
[Export(PropertyHint.Range, "0,50,0.1")]
|
||||||
|
public float MantleDashStrength { get; set; } = 15f;
|
||||||
|
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||||
|
public float MantleJumpStartVelocity { get; set; } = 20.0f;
|
||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
[ExportGroup("Jump")]
|
[ExportGroup("Jump")]
|
||||||
[Export(PropertyHint.Range, "0,1,0.01")]
|
[Export(PropertyHint.Range, "0,1,0.01")]
|
||||||
@@ -207,7 +224,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private StateChartState _grounded;
|
private StateChartState _grounded;
|
||||||
private StateChartState _airborne;
|
private StateChartState _airborne;
|
||||||
private StateChartState _coyoteEnabled;
|
private StateChartState _coyoteEnabled;
|
||||||
// private StateChartState _doubleJumpEnabled;
|
|
||||||
private StateChartState _simpleJump;
|
private StateChartState _simpleJump;
|
||||||
private StateChartState _doubleJump;
|
private StateChartState _doubleJump;
|
||||||
private StateChartState _megaJump;
|
private StateChartState _megaJump;
|
||||||
@@ -231,7 +247,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private Transition _onLeaveWallFromRunCoyote;
|
private Transition _onLeaveWallFromRunCoyote;
|
||||||
private Transition _onLeaveWallFromRun;
|
private Transition _onLeaveWallFromRun;
|
||||||
|
|
||||||
private int _currentJumpBufferFrames = 0;
|
private int _currentInputBufferFrames;
|
||||||
|
|
||||||
private float _playerHeight;
|
private float _playerHeight;
|
||||||
private float _playerRadius;
|
private float _playerRadius;
|
||||||
@@ -471,11 +487,28 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
if (_simpleDashCooldownTimer.IsStopped())
|
if (_simpleDashCooldownTimer.IsStopped())
|
||||||
_simpleDashCooldownTimer.Start();
|
_simpleDashCooldownTimer.Start();
|
||||||
|
|
||||||
if (_currentJumpBufferFrames > 0)
|
if (_bufferedAction == BufferedActions.Jump && _currentInputBufferFrames > 0)
|
||||||
{
|
{
|
||||||
_currentJumpBufferFrames = 0;
|
_currentInputBufferFrames = 0;
|
||||||
PerformJump();
|
PerformJump();
|
||||||
}
|
}
|
||||||
|
if (_bufferedAction == BufferedActions.Dash && _currentInputBufferFrames > 0)
|
||||||
|
{
|
||||||
|
_currentInputBufferFrames = 0;
|
||||||
|
SimpleDash();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_bufferedAction == BufferedActions.MantleJump)
|
||||||
|
{
|
||||||
|
SimpleDash();
|
||||||
|
OnJumpStarted(MantleJumpStartVelocity);
|
||||||
|
}
|
||||||
|
if (_bufferedAction == BufferedActions.MantleDash)
|
||||||
|
{
|
||||||
|
SimpleDash(MantleDashStrength);
|
||||||
|
}
|
||||||
|
|
||||||
|
_bufferedAction = BufferedActions.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DashCooldownTimeout()
|
public void DashCooldownTimeout()
|
||||||
@@ -649,8 +682,10 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
// Jump
|
// Jump
|
||||||
public void OnInputJumpStarted()
|
public void OnInputJumpStarted()
|
||||||
{
|
{
|
||||||
_currentJumpBufferFrames = InputBufferFrames;
|
_currentInputBufferFrames = InputBufferFrames;
|
||||||
|
_bufferedAction = _mantling.Active ? BufferedActions.MantleJump : BufferedActions.Jump;
|
||||||
_isJumpInputPressed = true;
|
_isJumpInputPressed = true;
|
||||||
|
|
||||||
PerformJump();
|
PerformJump();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,8 +839,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
private Vector3 _velocityOnMantleStarted = Vector3.Zero;
|
private Vector3 _velocityOnMantleStarted = Vector3.Zero;
|
||||||
|
|
||||||
private bool _mantleEndedOnOtherSideOfWall = false;
|
private bool _mantleEndedOnOtherSideOfWall;
|
||||||
private bool _mantleFoundGround = false;
|
private bool _mantleFoundGround;
|
||||||
public void OnMantleStarted()
|
public void OnMantleStarted()
|
||||||
{
|
{
|
||||||
HeadSystem.OnMantle();
|
HeadSystem.OnMantle();
|
||||||
@@ -840,14 +875,15 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
GlobalPosition = _mantlePath.Target.GlobalPosition;
|
GlobalPosition = _mantlePath.Target.GlobalPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SimpleDashInDirection(Vector3 direction)
|
public void SimpleDashInDirection(Vector3 direction, float strength = -1)
|
||||||
{
|
{
|
||||||
SetVelocity(direction * SimpleDashStrength);
|
if (strength < 0) strength = SimpleDashStrength;
|
||||||
|
SetVelocity(direction * strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SimpleDash()
|
public void SimpleDash(float strength = -1)
|
||||||
{
|
{
|
||||||
SimpleDashInDirection(GetInputGlobalHDirection());
|
SimpleDashInDirection(GetInputGlobalHDirection(), strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MantleFinished()
|
public void MantleFinished()
|
||||||
@@ -1015,6 +1051,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_canDashAirborne = false;
|
_canDashAirborne = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentInputBufferFrames = InputBufferFrames;
|
||||||
|
_bufferedAction = _mantling.Active ? BufferedActions.MantleDash : BufferedActions.Dash;
|
||||||
_playerState.SendEvent("dash");
|
_playerState.SendEvent("dash");
|
||||||
}
|
}
|
||||||
public void OnAimingEntered()
|
public void OnAimingEntered()
|
||||||
@@ -1427,7 +1465,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
///////////////////////////
|
///////////////////////////
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
if (_currentJumpBufferFrames > 0) _currentJumpBufferFrames -= 1;
|
if (_currentInputBufferFrames > 0) _currentInputBufferFrames -= 1;
|
||||||
|
|
||||||
LookAround(delta);
|
LookAround(delta);
|
||||||
CameraModifications((float) delta);
|
CameraModifications((float) delta);
|
||||||
|
|||||||
Reference in New Issue
Block a user