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

@@ -23,7 +23,7 @@ public partial class DashSystem: Node3D
public MantleSystem MantleSystem { get; set; }
private HeadSystem _head;
private ShapeCast3D _dashCast3D;
public ShapeCast3D DashCast3D;
private Camera3D _camera;
private Vector3 _dashDirection = Vector3.Zero;
@@ -51,8 +51,8 @@ public partial class DashSystem: Node3D
public void Init(HeadSystem head, Camera3D camera)
{
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
var dashShape = _dashCast3D.GetShape() as SphereShape3D;
DashCast3D = GetNode<ShapeCast3D>("DashCast3D");
var dashShape = DashCast3D.GetShape() as SphereShape3D;
DashCastRadius = dashShape!.Radius;
_dashCastDrop = GetNode<ShapeCast3D>("DashCastDrop");
@@ -75,25 +75,25 @@ public partial class DashSystem: Node3D
private DashLocation ComputeDashLocation()
{
var targetLocation = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition);
var hasHit = _dashCast3D.IsColliding();
var targetLocation = DashCast3D.ToGlobal(DashCast3D.TargetPosition);
var hasHit = DashCast3D.IsColliding();
if (!hasHit)
{
return new DashLocation(false, targetLocation, Vector3.Zero, Vector3.Zero);
}
var collisionPoint = _dashCast3D.GetCollisionPoint(0);
var collisionNormal = _dashCast3D.GetCollisionNormal(0);
var collisionPoint = DashCast3D.GetCollisionPoint(0);
var collisionNormal = DashCast3D.GetCollisionNormal(0);
var fraction = _dashCast3D.GetClosestCollisionSafeFraction();
var globalSweepPath = targetLocation - _dashCast3D.GlobalPosition;
var locationAlongPath = _dashCast3D.GlobalPosition + globalSweepPath * fraction;
var fraction = DashCast3D.GetClosestCollisionSafeFraction();
var globalSweepPath = targetLocation - DashCast3D.GlobalPosition;
var locationAlongPath = DashCast3D.GlobalPosition + globalSweepPath * fraction;
return new DashLocation(true, locationAlongPath, collisionPoint, collisionNormal);
}
public void PrepareDash()
{
_dashCast3D.SetRotation(_head.GetGlobalLookRotation());
DashCast3D.SetRotation(_head.GetGlobalLookRotation());
(HasHit, PlannedLocation, CollisionPoint, CollisionNormal) = ComputeDashLocation();
@@ -126,7 +126,7 @@ public partial class DashSystem: Node3D
// End of the drop is either max cast distance or first collision
var hasDropLocationHit = _dashCastDrop.IsColliding();
var endDropLocation = hasDropLocationHit ? _dashCastDrop.GetCollisionPoint(0) : _dashCastDrop.ToGlobal(_dashCast3D.TargetPosition);
var endDropLocation = hasDropLocationHit ? _dashCastDrop.GetCollisionPoint(0) : _dashCastDrop.ToGlobal(DashCast3D.TargetPosition);
// Only show drop location indicator if drop cast has hit
_dashDropLocationIndicator.SetVisible(hasDropLocationHit);