dash drop indicators
This commit is contained in:
@@ -27,6 +27,10 @@ public partial class DashSystem: Node3D
|
||||
private Camera3D _camera;
|
||||
private TweenQueueSystem _tweenQueueSystem;
|
||||
private Vector3 _dashDirection = Vector3.Zero;
|
||||
|
||||
private ShapeCast3D _dashCastDrop;
|
||||
private MeshInstance3D _dashDropIndicator;
|
||||
private MeshInstance3D _dashDropLocationIndicator;
|
||||
|
||||
private MantleSystem _mantleSystem;
|
||||
private MeshInstance3D _dashTarget;
|
||||
@@ -56,6 +60,12 @@ public partial class DashSystem: Node3D
|
||||
var dashShape = _dashCast3D.GetShape() as SphereShape3D;
|
||||
DashCastRadius = dashShape!.Radius;
|
||||
|
||||
_dashCastDrop = GetNode<ShapeCast3D>("DashCastDrop");
|
||||
_dashDropIndicator = GetNode<MeshInstance3D>("DashDropIndicator");
|
||||
_dashDropIndicator.Visible = false;
|
||||
_dashDropLocationIndicator = GetNode<MeshInstance3D>("DashDropLocationIndicator");
|
||||
_dashDropLocationIndicator.Visible = false;
|
||||
|
||||
_playerCast3D = GetNode<ShapeCast3D>("PlayerShapeCast3D");
|
||||
var playerShape = _playerCast3D.GetShape() as CapsuleShape3D;
|
||||
_playerHeight = playerShape!.Height;
|
||||
@@ -118,11 +128,35 @@ public partial class DashSystem: Node3D
|
||||
_dashTarget.SetVisible(true);
|
||||
var targetLocation = ShouldMantle ? PlannedMantleLocation : PlannedLocation;
|
||||
_dashTarget.SetGlobalPosition(targetLocation);
|
||||
|
||||
var shouldShowDropIndicator = !HasHit && !ShouldMantle;
|
||||
_dashDropIndicator.SetVisible(shouldShowDropIndicator);
|
||||
_dashDropLocationIndicator.SetVisible(shouldShowDropIndicator);
|
||||
if (shouldShowDropIndicator)
|
||||
{
|
||||
_dashCastDrop.GlobalPosition = targetLocation; // Place drop indication cast at dash location
|
||||
var startDropLocation = targetLocation; // Start of the drop is the dash target location
|
||||
|
||||
// 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);
|
||||
|
||||
// Only show drop location indicator if drop cast has hit
|
||||
_dashDropLocationIndicator.SetVisible(hasDropLocationHit);
|
||||
_dashDropLocationIndicator.SetGlobalPosition(endDropLocation);
|
||||
|
||||
var dropLength = (endDropLocation - startDropLocation).Length();
|
||||
var dropDirection = (endDropLocation - startDropLocation).Normalized();
|
||||
_dashDropIndicator.SetScale(new Vector3(1, dropLength, 1));
|
||||
_dashDropIndicator.SetGlobalPosition(startDropLocation + dropDirection * dropLength * 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public void StopPreparingDash()
|
||||
{
|
||||
_dashTarget.SetVisible(false);
|
||||
_dashDropIndicator.SetVisible(false);
|
||||
_dashDropLocationIndicator.SetVisible(false);
|
||||
}
|
||||
|
||||
public void StartPreparingDash()
|
||||
|
||||
Reference in New Issue
Block a user