dash drop indicators
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 13s
Create tag and build when new code gets to main / Export (push) Successful in 8m13s

This commit is contained in:
2025-10-20 11:42:14 +02:00
parent 70e3f70bcc
commit 916ff1921c
2 changed files with 58 additions and 1 deletions

View File

@@ -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()

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://cqduhd4opgwvm"]
[gd_scene load_steps=10 format=3 uid="uid://cqduhd4opgwvm"]
[ext_resource type="Script" uid="uid://dwoppk8j5fxeg" path="res://systems/dash/DashSystem.cs" id="1_hwig2"]
[ext_resource type="Shape3D" uid="uid://keseacdcooot" path="res://player_controller/resources/PlayerShape.tres" id="2_jngg2"]
@@ -11,6 +11,15 @@
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v31n3"]
[sub_resource type="CylinderMesh" id="CylinderMesh_jngg2"]
top_radius = 0.1
bottom_radius = 0.1
height = 1.0
[sub_resource type="TorusMesh" id="TorusMesh_tqt6i"]
inner_radius = 0.1
outer_radius = 0.5
[node name="DashSystem" type="Node3D"]
script = ExtResource("1_hwig2")
DashIndicatorScene = ExtResource("2_tqt6i")
@@ -30,6 +39,14 @@ max_results = 1
collision_mask = 2
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
[node name="DashCastDrop" type="ShapeCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 1.6, 0)
shape = SubResource("SphereShape3D_jngg2")
target_position = Vector3(0, 0, -50)
max_results = 1
collision_mask = 2
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
[node name="DashTarget" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_qu4wy")
surface_material_override/0 = SubResource("StandardMaterial3D_v31n3")
@@ -40,3 +57,9 @@ MantleHeightCastStart = 2.0
[node name="DashIndicator" parent="." instance=ExtResource("2_tqt6i")]
visible = false
[node name="DashDropIndicator" type="MeshInstance3D" parent="."]
mesh = SubResource("CylinderMesh_jngg2")
[node name="DashDropLocationIndicator" type="MeshInstance3D" parent="."]
mesh = SubResource("TorusMesh_tqt6i")