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);
|
_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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ public partial class MantleSystem: Node3D
|
|||||||
private ShapeCast3D _mantleCast3D;
|
private ShapeCast3D _mantleCast3D;
|
||||||
private RayCast3D _mantleCheckCast3D;
|
private RayCast3D _mantleCheckCast3D;
|
||||||
|
|
||||||
private Option<Vector3> _mantleLocation;
|
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
_wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D");
|
_wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D");
|
||||||
|
|||||||
Reference in New Issue
Block a user