they can hear now too

This commit is contained in:
derek
2025-05-02 15:52:07 -05:00
parent 083f1eec83
commit 88a60d469e
9 changed files with 131 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=4 uid="uid://b0rkkp07y3fnu"]
[gd_scene load_steps=33 format=4 uid="uid://b0rkkp07y3fnu"]
[ext_resource type="Script" uid="uid://bdecyikiye08i" path="res://scripts/die_particles.gd" id="1_frf2k"]
[ext_resource type="AudioStream" uid="uid://wd061pl0d7rl" path="res://assets/Audio/deep-low-explosion-SBA-300054677.wav" id="2_ddmln"]
@@ -7,6 +7,7 @@
[ext_resource type="Texture2D" uid="uid://b4s3w1qnqcmgq" path="res://assets/Models/spider1.gunbarrel.albedo.png" id="4_pb8pm"]
[ext_resource type="Texture2D" uid="uid://d4l5wf34qdvli" path="res://assets/Models/spider1.turret.png" id="5_hogev"]
[ext_resource type="Texture2D" uid="uid://dvq3rjpbugepj" path="res://assets/Models/spider1.turret.roughness1.png" id="6_0fxbp"]
[ext_resource type="Texture2D" uid="uid://dn3b6uw8xr63m" path="res://assets/Textures/Smoke/smoketest_v1_0043.png" id="8_taup3"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rgii8"]
resource_name = "spider1.turret"
@@ -253,6 +254,58 @@ shadow_mesh = SubResource("ArrayMesh_lj803")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_6s52t"]
points = PackedVector3Array(0.0373867, 0.506736, 0.264769, -0.356717, -0.359168, -0.355095, -0.0320077, -0.359938, -0.355895, -0.354628, -0.356682, 0.361267, 0.420766, -0.216171, 0.424228, 0.423749, 0.219941, -0.416246, -0.365389, 0.352423, -0.345166, -0.416466, 0.218879, 0.424331, 0.360266, -0.357965, -0.353736, 0.102349, 0.335027, 0.589588, 0.402901, 0.268555, 0.389875, 0.195153, 0.506736, -0.190996, -0.422081, -0.220248, -0.419715, -0.260721, 0.506736, 0.0369412, 0.358523, -0.35589, 0.360761, -0.0313043, 0.303622, 0.62754, -0.421842, 0.220812, -0.419429, 0.424319, -0.218587, -0.41693, -0.417407, -0.21707, 0.425083, -0.0479629, 0.437309, 0.542168, 0.265281, 0.506736, 0.0369412, 0.0869742, 0.203613, -0.452175, -0.0502516, 0.506736, -0.26119, -0.365015, 0.352134, 0.35648, 0.102079, 0.434188, 0.505107, 0.0358136, 0.235707, 0.625416, 0.355023, 0.353852, -0.363978, 0.419586, 0.218443, 0.423284, 0.358118, 0.356357, 0.360453, -0.350469, 0.353856, -0.36409, -0.208103, 0.506736, 0.176999, -0.208103, 0.506736, -0.17353)
[sub_resource type="Curve" id="Curve_t6371"]
_data = [Vector2(0, 0), 0.0, 1.4, 0, 0, Vector2(0.5, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 3
[sub_resource type="CurveTexture" id="CurveTexture_ya0uq"]
curve = SubResource("Curve_t6371")
[sub_resource type="Gradient" id="Gradient_5x7p8"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_8kfxe"]
gradient = SubResource("Gradient_5x7p8")
[sub_resource type="Curve" id="Curve_cecki"]
_limits = [-1.0, 1.0, 0.0, 1.0]
_data = [Vector2(0, -1), 0.0, 2.8, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_aqpqn"]
curve = SubResource("Curve_cecki")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_m0rco"]
particle_flag_rotate_y = true
emission_shape = 1
emission_sphere_radius = 0.1
velocity_pivot = Vector3(0, 1, 0)
direction = Vector3(1, 1, 1)
spread = 180.0
initial_velocity_min = 10.0
initial_velocity_max = 30.0
gravity = Vector3(0, 0.5, 0)
scale_min = 0.1
color_ramp = SubResource("GradientTexture1D_8kfxe")
alpha_curve = SubResource("CurveTexture_ya0uq")
hue_variation_curve = SubResource("CurveTexture_aqpqn")
turbulence_enabled = true
turbulence_noise_strength = 0.0
turbulence_noise_scale = 0.5
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pxrrg"]
transparency = 1
blend_mode = 1
shading_mode = 0
albedo_color = Color(1, 1, 1, 0.87451)
albedo_texture = ExtResource("8_taup3")
billboard_mode = 1
[sub_resource type="PlaneMesh" id="PlaneMesh_0eh43"]
material = SubResource("StandardMaterial3D_pxrrg")
size = Vector2(10, 10)
orientation = 2
[node name="dieParticles" type="Node3D" node_paths=PackedStringArray("audio_explode") groups=["spawned"]]
script = ExtResource("1_frf2k")
audio_explode = NodePath("Audio/Die")
@@ -301,3 +354,14 @@ skeleton = NodePath("")
[node name="CollisionShape3D" type="CollisionShape3D" parent="body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.03709, 0)
shape = SubResource("ConvexPolygonShape3D_6s52t")
[node name="dieParticles2" type="GPUParticles3D" parent="."]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
emitting = false
amount = 20
lifetime = 4.0
one_shot = true
explosiveness = 1.0
fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_m0rco")
draw_pass_1 = SubResource("PlaneMesh_0eh43")

View File

@@ -8,13 +8,13 @@
_data = [Vector2(0, 0), 0.0, 1.4, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_ya0uq"]
[sub_resource type="CurveTexture" id="CurveTexture_cc6tn"]
curve = SubResource("Curve_eqjwj")
[sub_resource type="Gradient" id="Gradient_acjgf"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_8kfxe"]
[sub_resource type="GradientTexture1D" id="GradientTexture1D_grqjc"]
gradient = SubResource("Gradient_acjgf")
[sub_resource type="Curve" id="Curve_w037p"]
@@ -22,7 +22,7 @@ _limits = [-1.0, 1.0, 0.0, 1.0]
_data = [Vector2(0, -1), 0.0, 2.8, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_aqpqn"]
[sub_resource type="CurveTexture" id="CurveTexture_ljatf"]
curve = SubResource("Curve_w037p")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_oxveh"]
@@ -36,14 +36,14 @@ initial_velocity_min = 10.0
initial_velocity_max = 30.0
gravity = Vector3(0, 0.5, 0)
scale_min = 0.1
color_ramp = SubResource("GradientTexture1D_8kfxe")
alpha_curve = SubResource("CurveTexture_ya0uq")
hue_variation_curve = SubResource("CurveTexture_aqpqn")
color_ramp = SubResource("GradientTexture1D_grqjc")
alpha_curve = SubResource("CurveTexture_cc6tn")
hue_variation_curve = SubResource("CurveTexture_ljatf")
turbulence_enabled = true
turbulence_noise_strength = 0.0
turbulence_noise_scale = 0.5
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pxrrg"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_varlv"]
transparency = 1
blend_mode = 1
shading_mode = 0
@@ -52,7 +52,7 @@ albedo_texture = ExtResource("2_cag6r")
billboard_mode = 1
[sub_resource type="PlaneMesh" id="PlaneMesh_pjpw2"]
material = SubResource("StandardMaterial3D_pxrrg")
material = SubResource("StandardMaterial3D_varlv")
size = Vector2(10, 10)
orientation = 2

View File

@@ -872,6 +872,8 @@ script = ExtResource("7_cwyr0")
enemy = NodePath("../..")
move_speed = 1.5
turret_speed = 0.5
poi_investigate = true
poi_change_to_search = true
[node name="Stunned" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
script = ExtResource("8_wpql0")
@@ -897,6 +899,8 @@ enemy = NodePath("../..")
[node name="Search" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
script = ExtResource("12_aasxo")
enemy = NodePath("../..")
poi_investigate = true
poi_update_waypoint_immediately = true
[node name="VisibilityArea" type="Area3D" parent="."]
collision_layer = 0

View File

@@ -12,7 +12,7 @@ config_version=5
config/name="First Person Test"
config/tags=PackedStringArray("fps")
run/main_scene="uid://cfaydhd6u5bmb"
run/main_scene="uid://f7e0v1r6ra6c"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="uid://6svuq1l83al5"

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://dsnddbrlqkav2"]
[gd_scene load_steps=18 format=3 uid="uid://dsnddbrlqkav2"]
[ext_resource type="Script" uid="uid://pm8n67yhip1p" path="res://scripts/sublevel.gd" id="1_8cuhv"]
[ext_resource type="PackedScene" uid="uid://c7dhavrt11u55" path="res://enemy_spawner.tscn" id="3_q77vb"]
@@ -6,6 +6,7 @@
[ext_resource type="Material" uid="uid://bjryln3so1lgw" path="res://assets/materials/prototype/prototype_green.tres" id="7_1bmnm"]
[ext_resource type="Material" uid="uid://br2pyyyl2n3cx" path="res://assets/materials/prototype/prototype1.tres" id="7_l3crk"]
[ext_resource type="PackedScene" uid="uid://c6bpysq1tjhy4" path="res://vendingmahcine.tscn" id="7_pr7m0"]
[ext_resource type="PackedScene" uid="uid://24slv0pyxcd5" path="res://assets/level_bounds.tscn" id="14_0jfcg"]
[ext_resource type="PackedScene" uid="uid://by3n26uvps8tb" path="res://assets/water_tower.tscn" id="14_yn32s"]
[ext_resource type="PackedScene" uid="uid://c5t4uqihf8q0i" path="res://scripts/chest_spawner.tscn" id="15_n0y5v"]
[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="16_p7sg0"]
@@ -21,6 +22,9 @@ polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Arr
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6yrih"]
albedo_color = Color(0.300579, 0.462784, 0.249767, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_8cuhv"]
size = Vector3(344.386, 649.865, 245.984)
[node name="EnemyWork" type="Node3D"]
script = ExtResource("1_8cuhv")
@@ -363,3 +367,8 @@ size = Vector3(7.11499, 0.388184, 7.87915)
[node name="ChestSpawner3" parent="." instance=ExtResource("15_n0y5v")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.14983, 26.3554, 70.1881)
size = Vector3(0.76001, 0.388184, 0.941406)
[node name="LevelBounds" parent="." instance=ExtResource("14_0jfcg")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="LevelBounds"]
shape = SubResource("BoxShape3D_8cuhv")

View File

@@ -24,24 +24,17 @@ func Physics_Update(delta):
#if navigation is finished get new point, otherwise continue on path
if enemy.nav_agent.is_navigation_finished():
get_new_point_of_interest()
if has_points_to_investigate():
get_new_point_of_interest()
else:
Transitioned.emit(self,"idle")
else:
move_to_nav_point(delta)
#do turret scan
turret_scan(Vector3(0,scan_direction,0),delta)
func get_new_point_of_interest():
if enemy.player_last_seen != null:
move_target = enemy.player_last_seen
enemy.player_last_seen = null
enemy.nav_agent.set_target_position(move_target)
elif enemy.points_of_interest.size() > 0:
var point_of_interest = enemy.points_of_interest.pop_back()
move_target = point_of_interest["point"]
enemy.nav_agent.set_target_position(move_target)
else:
Transitioned.emit(self,"idle")
func change_scan_direction():
scan_timer = scan_time

View File

@@ -6,6 +6,9 @@ class_name EnemyState
@export var body_turn_speed : float = 3
@export var turret_speed : float = 6.0
@export var can_see : bool = true # indicates whether the enemy is able to see things in the state
@export var poi_investigate : bool = false
@export var poi_change_to_search : bool = false
@export var poi_update_waypoint_immediately : bool = false
@export var time_to_lose_target = 1.0
@onready var target_lost_timer = time_to_lose_target
@@ -115,6 +118,38 @@ func turret_look3D(delta):
func turret_scan_look(target,scan_direction,delta):
enemy.turret_look.global_rotation.y = rotate_to_face2D(enemy.turret_look,target,scan_direction,delta,turret_speed)
func investigate_points_of_interest(point,loudness,max_distance):
if poi_investigate:
var distance_to_point = enemy.global_position.distance_to(point)
if distance_to_point <= max_distance:
var perceived_loudness = 1/distance_to_point * loudness
var add_point = {"point" : point, "loudness" : perceived_loudness}
enemy.points_of_interest.append(add_point)
if poi_change_to_search:
Transitioned.emit(self,"search")
if poi_update_waypoint_immediately:
get_new_point_of_interest()
func has_points_to_investigate():
if enemy.player_last_seen != null:
return true
elif enemy.points_of_interest.size() > 0:
return true
else:
return false
func get_new_point_of_interest():
if enemy.player_last_seen != null:
move_target = enemy.player_last_seen
enemy.player_last_seen = null
enemy.nav_agent.set_target_position(move_target)
elif enemy.points_of_interest.size() > 0:
var point_of_interest = enemy.points_of_interest.pop_back()
move_target = point_of_interest["point"]
enemy.nav_agent.set_target_position(move_target)
func clear_points_of_interest():
enemy.points_of_interest = []

View File

@@ -1,11 +1,13 @@
extends Node3D
@onready var die_particles = $dieParticles
@onready var die_particles_2: GPUParticles3D = $dieParticles2
@export var audio_explode : Node
# Called when the node enters the scene tree for the first time.
func _ready():
die_particles.emitting = true
die_particles_2.emitting = true
audio_explode.play()
# Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@@ -153,21 +153,7 @@ func cache_player_pos():
player_last_seen = line_of_sight_ray.get_collision_point()
func add_point_of_interest(point,loudness,max_distance):
var current_state_name = state_machine.current_state.name.to_lower()
if current_state_name == "idle" or current_state_name == "search":
var distance_to_point = global_position.distance_to(point)
if distance_to_point <= max_distance:
var perceived_loudness = 1/distance_to_point * loudness
var add_point = {"point" : point, "loudness" : perceived_loudness}
points_of_interest.append(add_point)
if current_state_name == "idle":
change_state_to("search")
if current_state_name == "search":
pass
#get new waypoint
#state_machine.current_state.investigate_points_of_interest()
state_machine.current_state.investigate_points_of_interest(point,loudness,max_distance)
func investigate_nearby_combat(ally,target):
if ally != self: