fixed a going through wall issue
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
[gd_scene load_steps=25 format=3 uid="uid://q7uc1h2jpbd2"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://q7uc1h2jpbd2"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_62kkh"]
|
||||
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/greybox/m_greybox.tres" id="2_3uydm"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/grounded_enemy/grounded_enemy.tscn" id="3_3uydm"]
|
||||
[ext_resource type="Script" uid="uid://b4cwruitopcee" path="res://components/health/RDeathEffect.cs" id="5_7m3bq"]
|
||||
[ext_resource type="PackedScene" uid="uid://cmlud1hwkd6sv" path="res://scenes/enemies/flying_enemy/flying_enemy.tscn" id="5_8fd2t"]
|
||||
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://components/knockback/RKnockback.cs" id="6_1hrkh"]
|
||||
[ext_resource type="PackedScene" uid="uid://c305mfrtumcyq" path="res://scenes/spawners/spawner.tscn" id="6_7m3bq"]
|
||||
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://components/movement/RMovement.cs" id="6_ybosk"]
|
||||
[ext_resource type="Resource" uid="uid://bqq6uukbdfysr" path="res://scenes/enemies/grounded_enemy/grounded_enemy_movement.tres" id="7_caohq"]
|
||||
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://components/health/RHealth.cs" id="9_2e4ci"]
|
||||
[ext_resource type="Resource" uid="uid://otfc2snh8umc" path="res://scenes/enemies/grounded_enemy/grounded_enemy_damage.tres" id="9_dmw1t"]
|
||||
@@ -38,29 +36,10 @@ ssil_radius = 8.4
|
||||
sdfgi_use_occlusion = true
|
||||
glow_enabled = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_sysok"]
|
||||
script = ExtResource("5_7m3bq")
|
||||
metadata/_custom_type_script = "uid://b4cwruitopcee"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_q21h6"]
|
||||
script = ExtResource("6_1hrkh")
|
||||
metadata/_custom_type_script = "uid://b44cse62qru7j"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5fa36"]
|
||||
script = ExtResource("6_ybosk")
|
||||
GravityModifier = 1.0
|
||||
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_blhrq"]
|
||||
script = ExtResource("6_ybosk")
|
||||
GravityModifier = 1.0
|
||||
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1hrkh"]
|
||||
script = ExtResource("6_ybosk")
|
||||
TargetHeight = 5.0
|
||||
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ybosk"]
|
||||
script = ExtResource("9_2e4ci")
|
||||
StartingHealth = 1.0
|
||||
@@ -141,31 +120,23 @@ material = ExtResource("2_3uydm")
|
||||
[node name="Enemy" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -16.83681)
|
||||
Target = NodePath("../Player")
|
||||
DeathEffects = Array[Object]([SubResource("Resource_sysok")])
|
||||
RKnockback = SubResource("Resource_q21h6")
|
||||
RMovement = SubResource("Resource_5fa36")
|
||||
|
||||
[node name="Enemy2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, -16.83681)
|
||||
Target = NodePath("../Player")
|
||||
RKnockback = SubResource("Resource_q21h6")
|
||||
RMovement = SubResource("Resource_blhrq")
|
||||
|
||||
[node name="Enemy3" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7, 0, 0.16319084)
|
||||
Target = NodePath("../Player")
|
||||
RKnockback = SubResource("Resource_q21h6")
|
||||
RMovement = SubResource("Resource_5fa36")
|
||||
|
||||
[node name="FlyingEnemy" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("5_8fd2t")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 7, -16)
|
||||
Target = NodePath("../Player")
|
||||
RMovement = SubResource("Resource_1hrkh")
|
||||
|
||||
[node name="FlyingEnemy2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("5_8fd2t")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 7, -16)
|
||||
Target = NodePath("../Player")
|
||||
RMovement = SubResource("Resource_1hrkh")
|
||||
|
||||
[node name="GroundedSpawner" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("6_7m3bq")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 2.5, -15)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user