fixed a going through wall issue

This commit is contained in:
2026-01-21 17:31:24 +01:00
parent db49703326
commit 8b2bf3e32e
3 changed files with 27 additions and 45 deletions

View File

@@ -1814,6 +1814,8 @@ public partial class PlayerController : CharacterBody3D,
///////////////////////////
public override void _PhysicsProcess(double delta)
{
_spaceState = GetWorld3D().DirectSpaceState;
if (_currentInputBufferFrames > 0) _currentInputBufferFrames -= 1;
// Manage head and camera movement
@@ -1926,17 +1928,26 @@ public partial class PlayerController : CharacterBody3D,
_audioStream!.SwitchToClipByName("attacks");
}
private PhysicsDirectSpaceState3D _spaceState;
public void OnDashAttackStarted()
{
_audioStream!.SwitchToClipByName("attacks");
_isInvincible = true;
var actualDashLocation = _targetLocation + Vector3.Down*HeadSystem.Position.Y;
var travel = actualDashLocation - GlobalPosition;
var plannedDashLocation = _targetLocation + Vector3.Down*HeadSystem.Position.Y;
var query = PhysicsRayQueryParameters3D.Create(HeadSystem.GlobalPosition, plannedDashLocation, DashSystem.DashCast3D.CollisionMask);
var result = _spaceState.IntersectRay(query);
if (result.Count > 0)
{
plannedDashLocation = (Vector3) result["position"];
}
var travel = plannedDashLocation - GlobalPosition;
_preDashVelocity = Velocity;
_dashDirection = travel.Normalized();
var dashTween = CreatePositionTween(actualDashLocation, AimedDashTime);
var dashTween = CreatePositionTween(plannedDashLocation, AimedDashTime);
dashTween.Finished += OnDashAttackEnded;
}