Navigation improvements

This commit is contained in:
Marco 2025-09-25 15:50:34 +02:00
commit 05047da6b3
7 changed files with 1033 additions and 549 deletions

View file

@ -511,7 +511,7 @@
}
// brush 56
{
( 256 -400 24 ) ( 256 -400 25 ) ( 256 -401 24 ) __TB_empty [ 1.4901161071382978e-08 -1 0 -8 ] [ 0 0 -1 8 ] 270 1 1
( 256 -400 24 ) ( 256 -400 25 ) ( 256 -401 24 ) special/clip [ 1.4901161071382978e-08 -1 0 -8 ] [ 0 0 -1 8 ] 270 1 1
( 256 -480 24 ) ( 255 -480 24 ) ( 256 -480 25 ) __TB_empty [ 0.9999999999999999 1.4901161071382978e-08 0 -8 ] [ 0 0 -1 8 ] 0 1 1
( 264 -264 16 ) ( 263 -264 16 ) ( 264 -265 16 ) __TB_empty [ 0.9999999999999999 1.4901161071382978e-08 0 -8 ] [ -1.4901161071382978e-08 1 0 8 ] 270 1 1
( 256 -400 48 ) ( 256 -401 48 ) ( 255 -400 48 ) Manual/Black [ -0.9999999999999999 -1.4901161071382978e-08 0 0 ] [ -1.4901161071382978e-08 1 0 0 ] 180 1 1
@ -2194,6 +2194,7 @@
{
"classname" "actor_door_1"
"origin" "-100 328 72"
"targetname" "door_2"
}
// entity 49
{
@ -2562,7 +2563,7 @@
// entity 108
{
"classname" "marker_spawn_enemy"
"origin" "164 56 22"
"origin" "164 64 22"
"resource_path" "res://Resources/Enemies/Fairy_Guard_3D.tres"
}
// entity 109
@ -2617,6 +2618,7 @@
"classname" "actor_door_1"
"origin" "-312 324 72"
"angles" "0 90 0"
"targetname" "door_3"
}
// entity 116
{
@ -2727,6 +2729,7 @@
{
"classname" "actor_door_1"
"origin" "-100 168 72"
"targetname" "door_5"
}
// entity 126
{
@ -2734,3 +2737,214 @@
"origin" "-252 120 76"
"angles" "0 90 0"
}
// entity 127
{
"classname" "actor_controlpad"
"origin" "-96 304 72"
"target" "door_2"
}
// entity 128
{
"classname" "actor_controlpad"
"origin" "-292 328 72"
"angles" "0 90 0"
"target" "door_3"
}
// entity 129
{
"classname" "actor_controlpad"
"origin" "-152 164 72"
"target" "door_5"
}
// entity 130
{
"classname" "actor_securitycamera"
"origin" "-272 24 76"
}
// entity 131
{
"classname" "actor_box_red"
"origin" "-216 24 60"
}
// entity 132
{
"classname" "actor_box_blue_tall"
"origin" "-172 28 65"
}
// entity 133
{
"classname" "actor_box_blue_tall"
"origin" "-256 80 65"
}
// entity 134
{
"classname" "actor_box_green"
"origin" "-192 44 60"
}
// entity 135
{
"classname" "actor_box_blue"
"origin" "-192 8 60"
}
// entity 136
{
"classname" "actor_box_blue"
"origin" "-192 24 60"
}
// entity 137
{
"classname" "actor_table"
"origin" "-156 12 60"
}
// entity 138
{
"classname" "actor_table"
"origin" "-140 12 60"
}
// entity 139
{
"classname" "actor_table"
"origin" "-124 12 60"
}
// entity 140
{
"classname" "actor_box_wood"
"origin" "-152 36 60"
"angles" "0 90 0"
}
// entity 141
{
"classname" "actor_box_wood"
"origin" "-136 36 60"
"angles" "0 90 0"
}
// entity 142
{
"classname" "actor_box_wood"
"origin" "-128 48 60"
"angles" "0 90 0"
}
// entity 143
{
"classname" "actor_box_wood"
"origin" "-120 36 60"
"angles" "0 90 0"
}
// entity 144
{
"classname" "actor_box_wood"
"origin" "-144 48 60"
"angles" "0 90 0"
}
// entity 145
{
"classname" "actor_locker"
"origin" "-268 0 68"
}
// entity 146
{
"classname" "actor_teleporter"
"origin" "-240 0 57"
}
// entity 147
{
"classname" "actor_tank_standalone"
"origin" "-400 128 64"
}
// entity 148
{
"classname" "actor_tank_standalone"
"origin" "-416 128 64"
}
// entity 149
{
"classname" "actor_tank_standalone"
"origin" "-432 128 64"
}
// entity 150
{
"classname" "actor_tank_standalone"
"origin" "-448 128 64"
}
// entity 151
{
"classname" "actor_tank_standalone"
"origin" "-464 128 64"
}
// entity 152
{
"classname" "actor_tube_straight_long"
"origin" "-464 128 80"
}
// entity 153
{
"classname" "actor_tube_straight_long"
"origin" "-464 160 80"
}
// entity 154
{
"classname" "actor_tube_straight_long"
"origin" "-464 192 80"
}
// entity 155
{
"classname" "actor_tube_straight_long"
"origin" "-464 240 80"
}
// entity 156
{
"classname" "actor_tube_straight_long"
"origin" "-464 272 80"
}
// entity 157
{
"classname" "actor_tube_straight_long"
"origin" "-464 304 80"
}
// entity 158
{
"classname" "actor_tube_straight"
"origin" "-464 216 80"
}
// entity 159
{
"classname" "marker_spawn_enemy"
"origin" "124 272 22"
"resource_path" "res://Resources/Enemies/Fairy_Guard_3D.tres"
}
// entity 160
{
"classname" "actor_box_blue_tall"
"origin" "176 8 25"
}
// entity 161
{
"classname" "actor_box_blue_tall"
"origin" "176 48 25"
}
// entity 162
{
"classname" "solid_bullet_permeable"
// brush 0
{
( 160 20 20 ) ( 160 21 20 ) ( 160 20 21 ) Various/Various3 [ -6.123233995736766e-17 -1 0 -4 ] [ 0 0 -1 8 ] 90 1 1
( 184 16 16 ) ( 183 16 16 ) ( 184 16 17 ) Various/Various3 [ 1 -6.123233995736766e-17 0 0 ] [ 0 0 -1 8 ] 270 1 1
( 184 16 16 ) ( 184 17 16 ) ( 183 16 16 ) Various/Various3 [ -6.123233995736766e-17 -1 0 -4 ] [ 1 -6.123233995736766e-17 0 0 ] 0 1 1
( 96 20 28 ) ( 95 20 28 ) ( 96 21 28 ) Various/Various3 [ 6.123233995736766e-17 1 0 4 ] [ 1 -6.123233995736766e-17 0 0 ] 90 1 1
( 96 20 20 ) ( 96 20 21 ) ( 95 20 20 ) Various/Various3 [ -1 6.123233995736766e-17 0 0 ] [ 0 0 -1 8 ] 270 1 1
( 184 16 16 ) ( 184 16 17 ) ( 184 17 16 ) Various/Various3 [ 6.123233995736766e-17 1 0 4 ] [ 0 0 -1 8 ] 270 1 1
}
}
// entity 163
{
"classname" "solid_bullet_permeable"
// brush 0
{
( 160 40 20 ) ( 160 41 20 ) ( 160 40 21 ) Various/Various3 [ -6.123233995736766e-17 -1 0 0 ] [ 0 0 -1 8 ] 0 1 1
( 184 36 16 ) ( 183 36 16 ) ( 184 36 17 ) Various/Various3 [ 1 -6.123233995736766e-17 0 0 ] [ 0 0 -1 8 ] 180 1 1
( 184 36 16 ) ( 184 37 16 ) ( 183 36 16 ) Various/Various3 [ -6.123233995736766e-17 -1 0 0 ] [ 1 -6.123233995736766e-17 0 0 ] 270 1 1
( 96 40 28 ) ( 95 40 28 ) ( 96 41 28 ) Various/Various3 [ 6.123233995736766e-17 1 0 0 ] [ 1 -6.123233995736766e-17 0 0 ] 0 1 1
( 96 40 20 ) ( 96 40 21 ) ( 95 40 20 ) Various/Various3 [ -1 6.123233995736766e-17 0 0 ] [ 0 0 -1 8 ] 180 1 1
( 184 36 16 ) ( 184 36 17 ) ( 184 37 16 ) Various/Various3 [ 6.123233995736766e-17 1 0 0 ] [ 0 0 -1 8 ] 180 1 1
}
}

View file

@ -4,6 +4,7 @@
[resource]
script = ExtResource("1_77qe7")
collision_layer = 512
collision_mask = 0
classname = "solid_bullet_permeable"
description = "Default static world geometry. Builds a StaticBody3D with a single MeshInstance3D and a single convex CollisionShape3D shape. Also builds Occluder3D to aid in render culling of other VisualInstance3D nodes.

File diff suppressed because one or more lines are too long

View file

@ -98,7 +98,7 @@ animations = [{
[node name="Enemy" type="CharacterBody3D" node_paths=PackedStringArray("EnemyFSM")]
collision_layer = 64
collision_mask = 17
collision_mask = 1553
script = ExtResource("1_a3crc")
EnemyFSM = NodePath("StateMachine")
EnemyResource = ExtResource("2_jgarc")

View file

@ -216,7 +216,7 @@ radius = 0.80566406
[node name="IsoPlayerFsm" type="CharacterBody3D" node_paths=PackedStringArray("PlayerFSM")]
collision_layer = 2
collision_mask = 17
collision_mask = 1553
script = ExtResource("1_cc7e7")
PlayerFSM = NodePath("StateMachine")

View file

@ -8,47 +8,77 @@ public partial class NavigationProvider3D : Node
private Vector3? _lastTargetPosition;
private CharacterBody3D _characterBody;
//private NavigationAgent3D _navigationAgent;
[Export] public NavigationAgent3D NavigationAgent { get; private set; }
[ExportCategory("References")]
[Export]
public EnemyStorage3D StorageModule { get; private set; }
public NavigationAgent3D NavigationAgent { get; private set; }
[Export] public EnemyStorage3D StorageModule { get; private set; }
[ExportCategory("Properties")]
[Export]
public float ProcessingRate { get; private set; } = 0.1f;
private Vector3? _nextPathPosition;
public void Init(CharacterBody3D characterBody)
{
_characterBody = characterBody;
if (NavigationAgent is not null) return;
//_navigationAgent = this.GetNode<NavigationAgent3D>("NavigationAgent");
// var timer = new Timer();
// this.AddChild(timer);
//
// timer.Timeout += TimerOnTimeout;
//
// timer.Start(ProcessingRate);
}
private void TimerOnTimeout()
{
if (!_lastTargetPosition.HasValue)
{
return;
}
if (NavigationAgent.IsNavigationFinished())
{
return;
}
_nextPathPosition = NavigationAgent.GetNextPathPosition();
}
public void SetTarget(Vector3? target)
{
_lastTargetPosition = target;
_lastTargetPosition = target;
}
public void Move(float movementSpeed)
{
if (!_lastTargetPosition.HasValue)
{
return;
}
NavigationAgent.SetTargetPosition(_lastTargetPosition.Value);
var currentAgentPosition = _characterBody.GlobalPosition;
if (NavigationAgent.IsNavigationFinished())
{
return;
}
var nextPathPosition = NavigationAgent.GetNextPathPosition();
var newVelocity = currentAgentPosition.DirectionTo(nextPathPosition) * movementSpeed;
_nextPathPosition = NavigationAgent.GetNextPathPosition();
var newVelocity = !_nextPathPosition.HasValue
? Vector3.Zero
: currentAgentPosition.DirectionTo(_nextPathPosition.Value) * movementSpeed;
newVelocity += StorageModule.KnockbackVelocity;
if (NavigationAgent.AvoidanceEnabled)
{
NavigationAgent.SetVelocity(newVelocity);
@ -57,10 +87,8 @@ public partial class NavigationProvider3D : Node
{
_on_navigation_agent_3d_velocity_computed(newVelocity);
}
}
public void _on_navigation_agent_3d_velocity_computed(Vector3 safeVelocity)
{
if (_characterBody is null) return;

View file

@ -410,6 +410,8 @@ locale/translations=PackedStringArray("res://Dialogue/Translations/dialogic_char
2d_physics/layer_9="Acid"
3d_physics/layer_9="Acid"
2d_physics/layer_10="Conveyor"
3d_physics/layer_10="Shoot-through"
3d_physics/layer_11="Transparent"
[navigation]