diff --git a/maps/levels/tuto_sword_parry.tscn b/maps/levels/tuto_sword_parry.tscn index bec79b3c..7788dda5 100644 --- a/maps/levels/tuto_sword_parry.tscn +++ b/maps/levels/tuto_sword_parry.tscn @@ -47,7 +47,7 @@ transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 35.5, 30.5, -42.5) transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 26, 30.5, -42.5) [node name="FixedDashthroughTarget7" parent="Targets" index="4" unique_id=282429016 instance=ExtResource("4_invhv")] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 10.5, 3.5, -9) +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 10.5, 5.5, -9) [node name="FixedDashthroughTarget6" parent="Targets" index="5" unique_id=437890277 instance=ExtResource("4_invhv")] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 8, 6, -30.5) @@ -236,37 +236,43 @@ Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy7" parent="GroundedEnemies" index="18" unique_id=1389063523 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy27" parent="GroundedEnemies" index="18" unique_id=883912991 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 13.5, 0, 1.1631908) +Target = NodePath("../../Player") +RHealth = SubResource("Resource_xy0m1") +RMovement = SubResource("Resource_nwk5u") + +[node name="Enemy7" parent="GroundedEnemies" index="19" unique_id=1389063523 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 25.5, 4, -27.33681) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy10" parent="GroundedEnemies" index="19" unique_id=836898496 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy10" parent="GroundedEnemies" index="20" unique_id=836898496 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 30.5, 11, -33.336807) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy8" parent="GroundedEnemies" index="20" unique_id=1015624071 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy8" parent="GroundedEnemies" index="21" unique_id=1015624071 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 34.5, 1.5, -27.33681) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy9" parent="GroundedEnemies" index="21" unique_id=827865590 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy9" parent="GroundedEnemies" index="22" unique_id=827865590 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 46.5, 0, -27.33681) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy5" parent="GroundedEnemies" index="22" unique_id=1267116862 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy5" parent="GroundedEnemies" index="23" unique_id=1267116862 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 4, 0, -18.33681) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy6" parent="GroundedEnemies" index="23" unique_id=1147823180 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy6" parent="GroundedEnemies" index="24" unique_id=1147823180 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 16.5, 7, -17.33681) Target = NodePath("../../Player") RHealth = SubResource("Resource_xy0m1") diff --git a/menus/scenes/overlaid_menus/toolbox.gd b/menus/scenes/overlaid_menus/toolbox.gd index 2a5f6bad..95ca4a89 100644 --- a/menus/scenes/overlaid_menus/toolbox.gd +++ b/menus/scenes/overlaid_menus/toolbox.gd @@ -26,6 +26,7 @@ func _on_player_invicible_toggled(toggled_on: bool) -> void: func _on_restart_current_level_pressed() -> void: SceneLoader.reload_current_scene() + close() func _on_select_level_pressed() -> void: diff --git a/scenes/fixed_dash_target/fixed_dashthrough_target.tscn b/scenes/fixed_dash_target/fixed_dashthrough_target.tscn index 87fbc03e..4017d543 100644 --- a/scenes/fixed_dash_target/fixed_dashthrough_target.tscn +++ b/scenes/fixed_dash_target/fixed_dashthrough_target.tscn @@ -18,7 +18,7 @@ emission_enabled = true emission = Color(0, 0.68968636, 0.7473501, 1) [node name="FixedDashthroughTarget" type="AnimatableBody3D" unique_id=1291663508] -collision_layer = 288 +collision_layer = 32 collision_mask = 0 script = ExtResource("1_r0j7a") diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index f1cc5d7b..8482d1cb 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -281,6 +281,7 @@ public partial class PlayerController : CharacterBody3D, private float _playerHeight; private float _playerRadius; private Vector3 _dashDirection = Vector3.Zero; + private Vector3 _postDashThroughPosition = Vector3.Zero; private Vector3 _preDashVelocity = Vector3.Zero; private int _empoweredActionsLeft; public int EmpoweredActionsLeft @@ -2093,26 +2094,32 @@ public partial class PlayerController : CharacterBody3D, } private PhysicsDirectSpaceState3D _spaceState; - public void StartDashAction(bool isParry) { var streamName = isParry ? "parry" : "attacks"; _audioStream!.SwitchToClipByName(streamName); IsInvincible = true; - 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 plannedDashLocation = _targetLocation + Vector3.Down*_playerHeight/2; + // var enemySurfaceQuery = PhysicsRayQueryParameters3D.Create(HeadSystem.GlobalPosition, plannedDashLocation, DashSystem.DashCast3D.CollisionMask); + // var enemySurfaceResult = _spaceState.IntersectRay(enemySurfaceQuery); + // if (enemySurfaceResult.Count > 0) + // { + // plannedDashLocation = (Vector3) enemySurfaceResult["position"]; + // } - var travel = plannedDashLocation - (GlobalPosition + Vector3.Up*_playerHeight/2); _preDashVelocity = Velocity; + var travel = plannedDashLocation - GlobalPosition; _dashDirection = travel.Normalized(); + + var postDashLocation = plannedDashLocation + 0.5f*travel; + var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask); + var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery); + var shouldRebound = wallBehindResult.Count > 0; + if (!shouldRebound) _postDashThroughPosition = postDashLocation; + var dashTween = CreatePositionTween(plannedDashLocation, AimedDashTime); - if (isParry) dashTween.Finished += OnDashParryEnded; + if (isParry || shouldRebound) dashTween.Finished += OnDashParryEnded; else dashTween.Finished += OnDashAttackEnded; } public void OnDashAttackStarted() @@ -2142,7 +2149,7 @@ public partial class PlayerController : CharacterBody3D, public void OnDashAttackEnded() { StopDashAction(); - GlobalPosition = ComputePositionAfterTargetedDash(_targetLocation, _targetHitLocation); + GlobalPosition = _postDashThroughPosition; var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? _preDashVelocity.Length() : PostDashSpeed; Velocity = _dashDirection * postDashVelocity; }