Fix issue where enemies will take a long time to attack after re-initiating combat timers.

Modified filth eater's behavior to shoot from far/attack from close
This commit is contained in:
2026-06-16 23:03:42 -07:00
parent f7c0476fa6
commit 9decb2a02d
5 changed files with 15 additions and 12 deletions
@@ -23,7 +23,7 @@ public partial class EngagePlayerBehavior : Node, IEngagePlayerBehavior
{
_actionTimer = new Timer();
_acquireTargetTimer = new Timer() { WaitTime = _acquireTargetTime };
_actionTimer.WaitTime = 0.8f;
_actionTimer.WaitTime = 0.5f;
_actionTimer.Timeout += OnAttackTimeout;
_acquireTargetTimer.Timeout += OnAcquireTargetTimeout;
AddChild(_actionTimer);
@@ -39,6 +39,7 @@ public partial class EngagePlayerBehavior : Node, IEngagePlayerBehavior
public void Disengage()
{
_actionTimer.Stop();
_actionTimer.WaitTime = 0.5f;
_acquireTargetTimer.Stop();
}
@@ -8,7 +8,7 @@
[ext_resource type="AudioStream" uid="uid://b7ycb6qvitpmw" path="res://src/audio/sfx/player_HITENEMY_3.ogg" id="7_kwkfv"]
[ext_resource type="PackedScene" uid="uid://cmhem5xknjsvc" path="res://src/enemy/behaviors/EngagePlayerBehavior.tscn" id="7_x8mrp"]
[ext_resource type="AudioStream" uid="uid://bf7adfdd857hw" path="res://src/audio/sfx/enemy_morph.ogg" id="8_upf7y"]
[ext_resource type="AudioStream" uid="uid://bn6ns3jxkw03b" path="res://src/audio/sfx/ENEMY_SPROING_death.ogg" id="9_fm627"]
[ext_resource type="AudioStream" uid="uid://bvokiqp1pqgfs" path="res://src/audio/sfx/ENEMY_michael_death.ogg" id="9_bun8r"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"]
height = 5.0
@@ -129,7 +129,7 @@ bus = &"SFX"
[node name="DieSFX" type="AudioStreamPlayer3D" parent="HitSounds"]
unique_name_in_owner = true
stream = ExtResource("9_fm627")
stream = ExtResource("9_bun8r")
bus = &"SFX"
[node name="AggroSFX" type="AudioStreamPlayer3D" parent="HitSounds"]
@@ -42,7 +42,7 @@ public partial class FilthEater : Enemy2D, IHavePatrolBehavior, IHaveEngagePlaye
public override void PerformAction()
{
var enemyPosition = new Vector3(GlobalPosition.X, _player.GlobalPosition.Y, GlobalPosition.Z);
if (enemyPosition.DistanceTo(_player.GlobalPosition) > 1)
if (enemyPosition.DistanceTo(_player.Position) > 4)
EnemyModelView.PlaySecondaryAttackAnimation();
else
EnemyModelView.PlayPrimaryAttackAnimation();
@@ -36,15 +36,15 @@ TertiaryAttackType = 0
metadata/_custom_type_script = ExtResource("4_5eid5")
[sub_resource type="CylinderShape3D" id="CylinderShape3D_g602r"]
height = 5.0
height = 13.8621
radius = 1.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_06aiy"]
radius = 2.5
radius = 1.8
height = 6.0
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ygtll"]
radius = 4.0
radius = 6.70264
[sub_resource type="SphereShape3D" id="SphereShape3D_ebx6c"]
radius = 2.64628
@@ -52,7 +52,7 @@ radius = 2.64628
[node name="FilthEater" type="CharacterBody3D" groups=["enemy"]]
process_mode = 1
collision_layer = 10
collision_mask = 11
collision_mask = 3
axis_lock_linear_y = true
axis_lock_angular_x = true
axis_lock_angular_z = true
@@ -71,7 +71,7 @@ collision_layer = 2
collision_mask = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="LineOfSight"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, -2)
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, -1.19209e-07, -6.43103)
shape = SubResource("CylinderShape3D_g602r")
[node name="Raycast" type="RayCast3D" parent="."]
@@ -83,7 +83,7 @@ debug_shape_custom_color = Color(1, 0, 0, 1)
[node name="CollisionShape" type="CollisionShape3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -0.0824751, 3.16485, 0)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -0.0824751, 3.16485, -0.0366802)
shape = SubResource("CapsuleShape3D_06aiy")
[node name="PlayerDetector" type="Area3D" parent="."]
@@ -125,6 +125,7 @@ _acquireTargetTime = 2.0
[node name="NavigationAgent" type="NavigationAgent3D" parent="Components"]
unique_name_in_owner = true
avoidance_enabled = true
radius = 3.0
use_3d_avoidance = true
avoidance_layers = 9
avoidance_mask = 9
@@ -23,7 +23,7 @@ height = 5.0
radius = 1.0
[sub_resource type="CylinderShape3D" id="CylinderShape3D_746fv"]
radius = 1.25
radius = 1.59424
[node name="Sara" type="CharacterBody3D" groups=["enemy"]]
process_mode = 1
@@ -92,7 +92,8 @@ unique_name_in_owner = true
[node name="EngagePlayerBehavior" parent="Components" instance=ExtResource("6_ddchx")]
unique_name_in_owner = true
_acquireTargetTime = 2.0
_minimumAttackTime = 1.5
_maximumAttackTime = 3.0
[node name="NavigationAgent" type="NavigationAgent3D" parent="Components"]
unique_name_in_owner = true