extended enemy dashthrough improvement to aimed dash behaviour
This commit is contained in:
@@ -1782,20 +1782,32 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
// feet of the capsule
|
// feet of the capsule
|
||||||
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;
|
||||||
|
var travel = correctedLocation - GlobalPosition;
|
||||||
|
_dashDirection = travel.Normalized();
|
||||||
|
|
||||||
|
var shouldRebound = false;
|
||||||
if (DashSystem.CanDashThroughTarget && DashSystem.CollidedObject is ITargetable targetable)
|
if (DashSystem.CanDashThroughTarget && DashSystem.CollidedObject is ITargetable targetable)
|
||||||
correctedLocation = ComputePositionAfterTargetedDash(targetable.GetTargetGlobalPosition(), DashSystem.CollisionPoint);
|
{
|
||||||
|
var plannedDashLocation = targetable.GetTargetGlobalPosition() + Vector3.Down*_playerHeight/2;
|
||||||
|
travel = plannedDashLocation - GlobalPosition;
|
||||||
|
_dashDirection = travel.Normalized();
|
||||||
|
var postDashLocation = plannedDashLocation + _dashDirection;
|
||||||
|
var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask);
|
||||||
|
var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery);
|
||||||
|
shouldRebound = wallBehindResult.Count > 0;
|
||||||
|
correctedLocation = shouldRebound ? plannedDashLocation : postDashLocation;
|
||||||
|
}
|
||||||
|
|
||||||
// Start invincibility timer for the duration of the dash and a bit more afterwards
|
// Start invincibility timer for the duration of the dash and a bit more afterwards
|
||||||
OnHitInvincibility();
|
OnHitInvincibility();
|
||||||
|
|
||||||
_preDashVelocity = Velocity;
|
_preDashVelocity = Velocity;
|
||||||
_dashDirection = (correctedLocation - GlobalPosition).Normalized();
|
|
||||||
SetupDashDamageDetector(correctedLocation);
|
SetupDashDamageDetector(correctedLocation);
|
||||||
|
|
||||||
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;
|
||||||
|
if (shouldRebound) dashTween.Finished += ManualKnockback;
|
||||||
|
|
||||||
_customMantle = DashSystem.ShouldMantle;
|
_customMantle = DashSystem.ShouldMantle;
|
||||||
_customMantleCurve = DashSystem.MantleSystem.MantleCurve;
|
_customMantleCurve = DashSystem.MantleSystem.MantleCurve;
|
||||||
@@ -2112,7 +2124,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
var travel = plannedDashLocation - GlobalPosition;
|
var travel = plannedDashLocation - GlobalPosition;
|
||||||
_dashDirection = travel.Normalized();
|
_dashDirection = travel.Normalized();
|
||||||
|
|
||||||
var postDashLocation = plannedDashLocation + 0.5f*travel;
|
var postDashLocation = plannedDashLocation + _dashDirection;
|
||||||
var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask);
|
var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask);
|
||||||
var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery);
|
var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery);
|
||||||
var shouldRebound = wallBehindResult.Count > 0;
|
var shouldRebound = wallBehindResult.Count > 0;
|
||||||
@@ -2122,6 +2134,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
if (isParry || shouldRebound) dashTween.Finished += OnDashParryEnded;
|
if (isParry || shouldRebound) dashTween.Finished += OnDashParryEnded;
|
||||||
else dashTween.Finished += OnDashAttackEnded;
|
else dashTween.Finished += OnDashAttackEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDashAttackStarted()
|
public void OnDashAttackStarted()
|
||||||
{
|
{
|
||||||
StartDashAction(isParry: false);
|
StartDashAction(isParry: false);
|
||||||
@@ -2156,6 +2169,11 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
public void OnDashParryEnded()
|
public void OnDashParryEnded()
|
||||||
{
|
{
|
||||||
StopDashAction();
|
StopDashAction();
|
||||||
|
ManualKnockback();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ManualKnockback()
|
||||||
|
{
|
||||||
Velocity = -_dashDirection*RKnockback.Modifier;
|
Velocity = -_dashDirection*RKnockback.Modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user