diff --git a/assets/audio/units/ant_move.wav b/assets/audio/units/ant_move.wav new file mode 100644 index 0000000..88920d1 --- /dev/null +++ b/assets/audio/units/ant_move.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c9e7b3a62466f049a20413d9a45d1baa2f1f0709e23e713d9938a9f58ec3adb +size 2037324 diff --git a/assets/audio/units/ant_move.wav.import b/assets/audio/units/ant_move.wav.import new file mode 100644 index 0000000..948deec --- /dev/null +++ b/assets/audio/units/ant_move.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ds7c5gkf1mssj" +path="res://.godot/imported/ant_move.wav-0265f62399d19f9a85ce5021aac88cdb.sample" + +[deps] + +source_file="res://assets/audio/units/ant_move.wav" +dest_files=["res://.godot/imported/ant_move.wav-0265f62399d19f9a85ce5021aac88cdb.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/audio/units/aphid_move.wav b/assets/audio/units/aphid_move.wav new file mode 100644 index 0000000..0dd9180 --- /dev/null +++ b/assets/audio/units/aphid_move.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:689d53a831e1f0dc7275176488c04d9c57c27f6031a276fd8d3730f767033224 +size 1345440 diff --git a/assets/audio/units/aphid_move.wav.import b/assets/audio/units/aphid_move.wav.import new file mode 100644 index 0000000..e5e2fb0 --- /dev/null +++ b/assets/audio/units/aphid_move.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bqt1xdorarhoi" +path="res://.godot/imported/aphid_move.wav-86075f01c7a2eff714e46b3c0d0d022d.sample" + +[deps] + +source_file="res://assets/audio/units/aphid_move.wav" +dest_files=["res://.godot/imported/aphid_move.wav-86075f01c7a2eff714e46b3c0d0d022d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/audio/units/bug_move_1.wav b/assets/audio/units/bug_move_1.wav new file mode 100644 index 0000000..efb03aa --- /dev/null +++ b/assets/audio/units/bug_move_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9babfecceab25405920c3a179e43ee98607cc444c7680fd7b74f6f25a76bf26a +size 615104 diff --git a/assets/audio/units/bug_move_1.wav.import b/assets/audio/units/bug_move_1.wav.import new file mode 100644 index 0000000..de18071 --- /dev/null +++ b/assets/audio/units/bug_move_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cqqq55wcilpwv" +path="res://.godot/imported/bug_move_1.wav-ca16a49a43f111816ed4d6c7eda91953.sample" + +[deps] + +source_file="res://assets/audio/units/bug_move_1.wav" +dest_files=["res://.godot/imported/bug_move_1.wav-ca16a49a43f111816ed4d6c7eda91953.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/audio/units/bug_move_2.wav b/assets/audio/units/bug_move_2.wav new file mode 100644 index 0000000..723cd18 --- /dev/null +++ b/assets/audio/units/bug_move_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:653785888738078855bd7e47c72fd87a7c21a4b308c90b8adda091263d5b3e52 +size 1134024 diff --git a/assets/audio/units/bug_move_2.wav.import b/assets/audio/units/bug_move_2.wav.import new file mode 100644 index 0000000..4280cda --- /dev/null +++ b/assets/audio/units/bug_move_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://d1cwg6l7mpw7h" +path="res://.godot/imported/bug_move_2.wav-ebcaed7cbf63144f44a996b003d6502e.sample" + +[deps] + +source_file="res://assets/audio/units/bug_move_2.wav" +dest_files=["res://.godot/imported/bug_move_2.wav-ebcaed7cbf63144f44a996b003d6502e.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/scenes/units/abstract/controlled_ant_unit.tscn b/scenes/units/abstract/controlled_ant_unit.tscn index 4b91dfc..b02e75b 100644 --- a/scenes/units/abstract/controlled_ant_unit.tscn +++ b/scenes/units/abstract/controlled_ant_unit.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=10 format=3 uid="uid://lbs0vilymbum"] +[gd_scene load_steps=11 format=3 uid="uid://lbs0vilymbum"] [ext_resource type="PackedScene" uid="uid://cidd3q2tet7ku" path="res://scenes/units/abstract/controlled_unit.tscn" id="1_66kao"] [ext_resource type="Script" path="res://scripts/units/abstract/controlled_ant_unit.gd" id="2_77pj2"] [ext_resource type="PackedScene" uid="uid://bi231xk2sp410" path="res://assets/models/ant.glb" id="2_e21vo"] +[ext_resource type="AudioStream" uid="uid://ds7c5gkf1mssj" path="res://assets/audio/units/ant_move.wav" id="4_80pw8"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jem3o"] animation = &"idle" @@ -81,4 +82,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.65, 0) [node name="SelectionIndicator" parent="." index="7"] transform = Transform3D(0.772715, 0, 0, 0, 0.772715, 0, 0, 0, 0.772715, 0, 0, 0) +[node name="MoveSoundPlayer" parent="." index="10"] +stream = ExtResource("4_80pw8") + [editable path="AntModel"] diff --git a/scenes/units/abstract/unit.tscn b/scenes/units/abstract/unit.tscn index 719d197..c5003e6 100644 --- a/scenes/units/abstract/unit.tscn +++ b/scenes/units/abstract/unit.tscn @@ -46,4 +46,10 @@ visible = false mesh = SubResource("BoxMesh_hvf81") [node name="SoundEffectsPlayer" type="AudioStreamPlayer3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0) script = ExtResource("3_wl62h") + +[node name="MoveSoundPlayer" type="AudioStreamPlayer3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0) +attenuation_model = 1 +attenuation_filter_db = 0.0 diff --git a/scenes/units/aphid.tscn b/scenes/units/aphid.tscn index a727036..8e89e36 100644 --- a/scenes/units/aphid.tscn +++ b/scenes/units/aphid.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=11 format=3 uid="uid://bw8cabkva3k4f"] +[gd_scene load_steps=12 format=3 uid="uid://bw8cabkva3k4f"] [ext_resource type="PackedScene" uid="uid://c70vx0utm5knp" path="res://scenes/units/abstract/unit.tscn" id="1_ghhpv"] [ext_resource type="Script" path="res://scripts/units/aphid.gd" id="2_c6sy4"] [ext_resource type="PackedScene" uid="uid://ch02ae8fj2lhh" path="res://assets/models/aphid.glb" id="2_vtmi4"] [ext_resource type="Material" uid="uid://f5ibq3dhugoo" path="res://resources/materials/aphid_mat.tres" id="3_b828p"] +[ext_resource type="AudioStream" uid="uid://bqt1xdorarhoi" path="res://assets/audio/units/aphid_move.wav" id="5_f4mon"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f1f0e"] animation = &"idle" @@ -52,4 +53,8 @@ transform = Transform3D(0.759866, 0, 0, 0, 0.759866, 0, 0, 0, 0.759866, 0, 0, 0) [node name="UiOrigin" parent="." index="6"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.531, 0) +[node name="MoveSoundPlayer" parent="." index="9"] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.25, 0) +stream = ExtResource("5_f4mon") + [editable path="AphidModel"] diff --git a/scripts/units/abstract/unit.gd b/scripts/units/abstract/unit.gd index 4c4d26b..3f6c336 100644 --- a/scripts/units/abstract/unit.gd +++ b/scripts/units/abstract/unit.gd @@ -31,6 +31,7 @@ var _advance_anim_delta_accum: float = 0 @onready var audio_player: SoundEffectsPlayer = ( $SoundEffectsPlayer ) +@onready var move_audio_player: AudioStreamPlayer3D = $MoveSoundPlayer; func _ready() -> void: @@ -40,8 +41,11 @@ func _ready() -> void: assert(ui_origin != null, "ui_origin missing!") assert(anim_advance_indicator != null, "anim_advance_indicator missing!") assert(audio_player != null, "audio_player missing!") + assert(move_audio_player != null, "move_audio_player missing!") super._ready() + move_audio_player.pitch_scale += randf_range(-0.25, 0.25) + anim_advance_indicator.visible = false if _spawn_pos != null and _spawn_pos != Vector3.ZERO: global_position = _spawn_pos @@ -63,6 +67,7 @@ func _ready() -> void: func _process(delta: float) -> void: super._process(delta) _handle_animation(delta) + _handle_move_sound() showing_info = UiManager.unit_info.unit == self @@ -126,6 +131,16 @@ func _handle_animation(delta: float) -> void: anim_advance_indicator.visible = advance and DebugManager.enabled +func _handle_move_sound() -> void: + if move_audio_player.stream == null: + return + + if move_audio_player.playing and velocity.length() < _move_speed / 2: + move_audio_player.stop() + if not move_audio_player.playing and velocity.length() >= _move_speed / 2: + move_audio_player.play(randf() * move_audio_player.stream.get_length()) + + func _wander(delta: float) -> void: _wandering_timer -= delta if _wandering_timer <= 0: