gd,fix: player won't go through thin platforms from underneath, added a small cooldown to dash actions, remapped inputs a bit for gamefeel
This commit is contained in:
@ -39,9 +39,12 @@ public partial class PlayerController : CharacterBody3D
|
||||
private float _inputRotateY;
|
||||
private float _inputRotateFloorplane;
|
||||
|
||||
// Timers
|
||||
private Timer _coyoteTimer;
|
||||
private Timer _timeScaleAimInAirTimer;
|
||||
private Timer _timeAfterDashingTimer;
|
||||
private Timer _dashCooldownTimer;
|
||||
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float TimeScaleAimInAir { get; set; } = 0.2f;
|
||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||
@ -139,6 +142,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
||||
// State timers
|
||||
_coyoteTimer = GetNode<Timer>("CoyoteTime");
|
||||
_dashCooldownTimer = GetNode<Timer>("DashCooldown");
|
||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||
_timeAfterDashingTimer = GetNode<Timer>("TimeAfterDashing");
|
||||
|
||||
@ -229,8 +233,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnInputAimPressed()
|
||||
{
|
||||
GD.Print("InputAimPressed");
|
||||
_playerState.SendEvent("aim_pressed");
|
||||
}
|
||||
public void OnInputAimDown()
|
||||
{
|
||||
_playerState.SendEvent("aim_down");
|
||||
}
|
||||
public void OnInputAimReleased()
|
||||
{
|
||||
_playerState.SendEvent("aim_released");
|
||||
@ -267,18 +276,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
public void OnGrounded()
|
||||
{
|
||||
DashActionsLeft = MaxNumberOfDashActions;
|
||||
GD.Print(DashActionsLeft);
|
||||
}
|
||||
|
||||
public bool CanPerformDashAction()
|
||||
{
|
||||
return DashActionsLeft > 0;
|
||||
return DashActionsLeft > 0 && _dashCooldownTimer.IsStopped();
|
||||
}
|
||||
|
||||
public void PerformDashAction()
|
||||
{
|
||||
_dashCooldownTimer.Start();
|
||||
DashActionsLeft--;
|
||||
GD.Print(DashActionsLeft);
|
||||
}
|
||||
|
||||
// Jumping
|
||||
@ -376,7 +384,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
else if (WeaponSystem.PlantedState.Active)
|
||||
{
|
||||
// Should we try to resolve with mantle?
|
||||
DashSystem.DashResolve = new DashResolveRecord(false, WeaponSystem.PlayerDashLocation, Vector3.Zero);
|
||||
var dashLocation =
|
||||
DashSystem.ComputeDashLocationForPlayerShape(WeaponSystem.PlantLocation, WeaponSystem.PlantNormal);
|
||||
DashSystem.DashResolve = new DashResolveRecord(false, dashLocation, Vector3.Zero);
|
||||
}
|
||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||
DashSystem.Dash();
|
||||
@ -393,9 +403,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
GD.Print(WeaponSystem.GlobalRotation);
|
||||
// Store the weapon state before resetting it
|
||||
var isPlantedOnWall = Math.Abs(WeaponSystem.GlobalRotation.X) + Math.Abs(WeaponSystem.GlobalRotation.Z) < 0.3;
|
||||
var isPlantedUnderPlatform = WeaponSystem.GlobalRotation.X > 1 && Math.Abs(WeaponSystem.GlobalRotation.Y) > 1;
|
||||
var shouldDashToPlanted = WeaponSystem.PlantedState.Active && (isPlantedOnWall || isPlantedUnderPlatform);
|
||||
var isPlantedOnWall = WeaponSystem.IsPlantedInWall();
|
||||
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
||||
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
||||
var isFlying = WeaponSystem.FlyingState.Active;
|
||||
|
||||
// Get the weapon back
|
||||
@ -412,7 +422,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
return; // In case states aren't exclusives
|
||||
}
|
||||
|
||||
if (shouldDashToPlanted)
|
||||
if (shouldDashToHanging)
|
||||
{
|
||||
_playerState.SendEvent("dash_to_planted");
|
||||
return; // In case states aren't exclusives
|
||||
|
Reference in New Issue
Block a user