aim dashing through targetable entities now possible

This commit is contained in:
2026-01-24 13:49:16 +01:00
parent 4d419b9010
commit b84b7e4dd5
6 changed files with 80 additions and 41 deletions

View File

@@ -105,6 +105,7 @@ script = ExtResource("1_poq2x")
RDamage = SubResource("Resource_cb2lu")
RKnockback = SubResource("Resource_abfq8")
RHealth = SubResource("Resource_ue7xq")
TargetingDistance = 5.0
WalkSpeed = 7.5
AccelerationFloor = 4.0
DecelerationFloor = 3.0

View File

@@ -1653,15 +1653,14 @@ public partial class PlayerController : CharacterBody3D,
if (!CanPerformEmpoweredAction())
return;
DashSystem.StartPreparingDash();
DashIndicatorMesh.Visible = true;
// DashIndicatorMesh.Visible = true;
if (!isOnFloorCustom())
ReduceTimeScaleWhileAiming();
}
public void HandleAiming(float delta)
{
DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
// DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
// DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
if (CanPerformEmpoweredAction())
DashSystem.PrepareDash();
@@ -1670,7 +1669,7 @@ public partial class PlayerController : CharacterBody3D,
{
DashSystem.StopPreparingDash();
DashIndicatorMesh.Visible = false;
// DashIndicatorMesh.Visible = false;
}
///////////////////////////
@@ -1701,7 +1700,14 @@ public partial class PlayerController : CharacterBody3D,
// feet of the capsule
var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius;
var correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction;
if (DashSystem.CanDashThroughTarget && DashSystem.CollidedObject is ITargetable targetable)
correctedLocation = ComputePositionAfterTargetedDash(targetable.GetTargetGlobalPosition(), DashSystem.CollisionPoint);
if (DashSystem.CollidedObject is IDamageable damageable)
_hitEnemies.Add(damageable);
// Start invincibility timer for the duration of the dash and a bit more afterwards
OnHitInvincibility();
_preDashVelocity = Velocity;
_dashDirection = (correctedLocation - GlobalPosition).Normalized();
@@ -1720,6 +1726,8 @@ public partial class PlayerController : CharacterBody3D,
}
public void OnAimedDashFinished()
{
TriggerDamage();
if (_customMantle)
{
_playerState.SendEvent("mantle");
@@ -1829,20 +1837,18 @@ public partial class PlayerController : CharacterBody3D,
MantleSystem.ProcessMantle(_grounded.Active);
HandleEnemyTargeting();
if (_closeEnemyDetector.IsColliding())
// Manage dash target and tutorial specific stuff
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
{
DashIndicatorMesh.Visible = false;
}
if (!WeaponSystem.InHandState.Active && TutorialDone)
{
DashIndicatorMesh.Visible = true;
DashIndicatorMeshCylinder.Height = WeaponSystem.GlobalPosition.DistanceTo(GlobalPosition) * 2;
DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition);
}
// if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
// {
// DashIndicatorMesh.Visible = false;
// }
// if (!WeaponSystem.InHandState.Active && TutorialDone)
// {
// DashIndicatorMesh.Visible = true;
//
// DashIndicatorMeshCylinder.Height = WeaponSystem.GlobalPosition.DistanceTo(GlobalPosition) * 2;
// DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition);
// }
}
///////////////////////////
@@ -1857,9 +1863,19 @@ public partial class PlayerController : CharacterBody3D,
{
_isEnemyInDashAttackRange = false;
_closeEnemyDetector.SetRotation(HeadSystem.GetGlobalLookRotation());
var enemyTargetState = PlayerUi.TargetState.NoTarget;
var positionOnScreen = Vector2.Zero;
if (DashSystem.CanDashThroughTarget && DashSystem.CollidedObject is ITargetable dashTarget)
{
enemyTargetState = PlayerUi.TargetState.TargetDashThrough;
_targetLocation = dashTarget.GetTargetGlobalPosition();
positionOnScreen = _camera.UnprojectPosition(_targetLocation);
PlayerUi.SetEnemyTargetProperties(new PlayerUi.TargetProperties(enemyTargetState, positionOnScreen));
return;
}
if (!_closeEnemyDetector.IsColliding())
{
PlayerUi.SetEnemyTargetProperties(new PlayerUi.TargetProperties(enemyTargetState, positionOnScreen));
@@ -1877,8 +1893,8 @@ public partial class PlayerController : CharacterBody3D,
_targetLocation = target.GetTargetGlobalPosition();
var targetDistance = _targetLocation.DistanceTo(GlobalPosition);
positionOnScreen = _camera.UnprojectPosition(_targetLocation);
_isEnemyInDashAttackRange = targetDistance < TargetInRangeDistance;
_isEnemyInDashAttackRange = true; //targetDistance < TargetInRangeDistance; // Removing the "almost dash" UI
if (_isEnemyInDashAttackRange)
{
enemyTargetState = PlayerUi.TargetState.TargetDashThrough;
@@ -1976,20 +1992,25 @@ public partial class PlayerController : CharacterBody3D,
}
else
{
var locationOtherSide = _targetLocation + (_targetLocation - _targetHitLocation);
GlobalPosition = locationOtherSide;
GlobalPosition = ComputePositionAfterTargetedDash(_targetLocation, _targetHitLocation);
var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? _preDashVelocity.Length() : PostDashSpeed;
Velocity = _dashDirection * postDashVelocity;
}
_isInvincible = false;
_playerState.SendEvent("attack_finished");
}
public Vector3 ComputePositionAfterTargetedDash(Vector3 targetLocation, Vector3 targetHitLocation)
{
return targetLocation + (targetLocation - targetHitLocation);
}
public void OnInputHitPressed()
{
if (_aiming.Active && WeaponSystem.InHandState.Active)
{
ThrowWeapon();
return;
}
var attackToDo = _isEnemyInDashAttackRange ? "dash_attack" : "standard_attack";