keeping more intertia after dashes and mantles
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -823,6 +823,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerState.SendEvent(resultingEvent);
|
||||
}
|
||||
|
||||
private Vector3 _preDashVelocity = Vector3.Zero;
|
||||
|
||||
public void OnAimedDashStarted()
|
||||
{
|
||||
// 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 correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction;
|
||||
|
||||
_preDashVelocity = Velocity;
|
||||
_dashDirection = (correctedLocation - GlobalPosition).Normalized();
|
||||
|
||||
var dashTween = CreatePositionTween(correctedLocation, AimedDashTime);
|
||||
// dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime);
|
||||
dashTween.Finished += AimedDashTweenEnded;
|
||||
@@ -880,6 +885,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnAimedDashFinished()
|
||||
{
|
||||
var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? PostDashSpeed : _preDashVelocity.Length();
|
||||
Velocity = _dashDirection * postDashVelocity;
|
||||
|
||||
if (_shouldMantleOnDashEnded)
|
||||
MantleToLocation(_mantleLocation);
|
||||
}
|
||||
@@ -922,8 +930,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
public void OnPoweredDashFinished()
|
||||
{
|
||||
// Try mantling but don't know if this is useful
|
||||
if (CanMantle())
|
||||
MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap());
|
||||
// if (CanMantle())
|
||||
// MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap());
|
||||
}
|
||||
|
||||
public void FinishPoweredDash()
|
||||
@@ -967,13 +975,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
var mantleLocationResult = MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y);
|
||||
return mantleLocationResult.IsSome(out _);
|
||||
}
|
||||
|
||||
private Vector3 _preMantleVelocity = Vector3.Zero;
|
||||
public void MantleToLocation(Vector3 location)
|
||||
{
|
||||
_preMantleVelocity = Velocity;
|
||||
var mantleTween = CreatePositionTween(location, MantleTime);
|
||||
mantleTween.Finished += MantleFinished;
|
||||
}
|
||||
public void MantleFinished()
|
||||
{
|
||||
Velocity = _preMantleVelocity;
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ public partial class MantleSystem: Node3D
|
||||
private ShapeCast3D _wallInFrontCast3D;
|
||||
private ShapeCast3D _mantleCast3D;
|
||||
private RayCast3D _mantleCheckCast3D;
|
||||
|
||||
private Option<Vector3> _mantleLocation;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user