keeping more intertia after dashes and mantles
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 18s
Create tag and build when new code gets to main / Export (push) Successful in 6m6s

This commit is contained in:
2025-11-11 09:52:57 +01:00
parent 6051588f24
commit e70a2e7537
4 changed files with 14 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -823,6 +823,8 @@ public partial class PlayerController : CharacterBody3D
_playerState.SendEvent(resultingEvent); _playerState.SendEvent(resultingEvent);
} }
private Vector3 _preDashVelocity = Vector3.Zero;
public void OnAimedDashStarted() public void OnAimedDashStarted()
{ {
// Adjusting for player height, where the middle of the capsule should get to the dash location instead of the // Adjusting for player height, where the middle of the capsule should get to the dash location instead of the
@@ -830,6 +832,9 @@ public partial class PlayerController : CharacterBody3D
var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius; var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius;
var correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction; var correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction;
_preDashVelocity = Velocity;
_dashDirection = (correctedLocation - GlobalPosition).Normalized();
var dashTween = CreatePositionTween(correctedLocation, AimedDashTime); var dashTween = CreatePositionTween(correctedLocation, AimedDashTime);
// dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime); // dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime);
dashTween.Finished += AimedDashTweenEnded; dashTween.Finished += AimedDashTweenEnded;
@@ -880,6 +885,9 @@ public partial class PlayerController : CharacterBody3D
public void OnAimedDashFinished() public void OnAimedDashFinished()
{ {
var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? PostDashSpeed : _preDashVelocity.Length();
Velocity = _dashDirection * postDashVelocity;
if (_shouldMantleOnDashEnded) if (_shouldMantleOnDashEnded)
MantleToLocation(_mantleLocation); MantleToLocation(_mantleLocation);
} }
@@ -922,8 +930,8 @@ public partial class PlayerController : CharacterBody3D
public void OnPoweredDashFinished() public void OnPoweredDashFinished()
{ {
// Try mantling but don't know if this is useful // Try mantling but don't know if this is useful
if (CanMantle()) // if (CanMantle())
MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap()); // MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap());
} }
public void FinishPoweredDash() public void FinishPoweredDash()
@@ -967,13 +975,17 @@ public partial class PlayerController : CharacterBody3D
var mantleLocationResult = MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y); var mantleLocationResult = MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y);
return mantleLocationResult.IsSome(out _); return mantleLocationResult.IsSome(out _);
} }
private Vector3 _preMantleVelocity = Vector3.Zero;
public void MantleToLocation(Vector3 location) public void MantleToLocation(Vector3 location)
{ {
_preMantleVelocity = Velocity;
var mantleTween = CreatePositionTween(location, MantleTime); var mantleTween = CreatePositionTween(location, MantleTime);
mantleTween.Finished += MantleFinished; mantleTween.Finished += MantleFinished;
} }
public void MantleFinished() public void MantleFinished()
{ {
Velocity = _preMantleVelocity;
_playerState.SendEvent("grounded"); _playerState.SendEvent("grounded");
} }

View File

@@ -15,8 +15,6 @@ public partial class MantleSystem: Node3D
private ShapeCast3D _wallInFrontCast3D; private ShapeCast3D _wallInFrontCast3D;
private ShapeCast3D _mantleCast3D; private ShapeCast3D _mantleCast3D;
private RayCast3D _mantleCheckCast3D; private RayCast3D _mantleCheckCast3D;
private Option<Vector3> _mantleLocation;
public void Init() public void Init()
{ {