create AudioStreamPlayerPolyphonic

This commit is contained in:
2024-10-08 03:06:06 +10:00
parent ad331507e6
commit a8da79707c
4 changed files with 51 additions and 3 deletions

View File

@@ -37,7 +37,7 @@ callback_mode_process = 1
[node name="Gathering" parent="." index="8" instance=ExtResource("3_7b5q8")] [node name="Gathering" parent="." index="8" instance=ExtResource("3_7b5q8")]
[node name="NearbyItemsSearch" parent="Gathering" index="0"] [node name="NearbyItemsSearch" parent="Gathering" index="1"]
shape = SubResource("SphereShape3D_f7l1n") shape = SubResource("SphereShape3D_f7l1n")
[node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"] [node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"]

View File

@@ -10,9 +10,30 @@ radius = 4.0
[node name="AntNitwit" instance=ExtResource("1_w0xhf")] [node name="AntNitwit" instance=ExtResource("1_w0xhf")]
script = ExtResource("2_rfn2k") script = ExtResource("2_rfn2k")
[node name="Skeleton3D" parent="AntModel/Armature" index="0"]
bones/4/rotation = Quaternion(0.587858, -5.43255e-07, -3.94772e-07, 0.808964)
bones/6/rotation = Quaternion(0.330686, -3.0116e-14, -4.44141e-07, 0.943741)
bones/9/rotation = Quaternion(0.587858, 5.43255e-07, 3.94772e-07, 0.808964)
bones/11/rotation = Quaternion(0.330686, 3.0116e-14, 4.44141e-07, 0.943741)
bones/14/rotation = Quaternion(4.60304e-08, 0.0294697, 0.999566, -5.43234e-07)
bones/15/rotation = Quaternion(4.55913e-08, 0.0294697, 0.999566, -4.34329e-07)
bones/16/rotation = Quaternion(4.55913e-08, 0.0294697, 0.999566, -4.34329e-07)
bones/26/rotation = Quaternion(-0.221628, 0.221633, -0.671475, 0.671477)
bones/27/rotation = Quaternion(0.583948, -8.29882e-08, 2.36539e-06, 0.811791)
bones/28/rotation = Quaternion(-0.84146, 6.60837e-08, -6.26108e-06, 0.54032)
bones/30/rotation = Quaternion(0.583949, -2.24752e-07, 2.46641e-06, 0.811791)
bones/31/rotation = Quaternion(-0.84146, 1.69298e-07, -6.42962e-06, 0.54032)
bones/34/rotation = Quaternion(-0.841459, 1.31575e-07, -6.3826e-06, 0.540321)
bones/35/rotation = Quaternion(-0.221628, -0.221633, 0.671475, 0.671477)
bones/36/rotation = Quaternion(0.583948, 8.29882e-08, -2.36539e-06, 0.811791)
bones/37/rotation = Quaternion(-0.84146, -6.60837e-08, 6.26108e-06, 0.54032)
bones/39/rotation = Quaternion(0.583949, 2.24752e-07, -2.46641e-06, 0.811791)
bones/40/rotation = Quaternion(-0.84146, -1.69298e-07, 6.42962e-06, 0.54032)
bones/43/rotation = Quaternion(-0.841459, -1.31575e-07, 6.3826e-06, 0.540321)
[node name="Gathering" parent="." index="8" instance=ExtResource("4_k3phm")] [node name="Gathering" parent="." index="8" instance=ExtResource("4_k3phm")]
[node name="NearbyItemsSearch" parent="Gathering" index="0"] [node name="NearbyItemsSearch" parent="Gathering" index="1"]
shape = SubResource("SphereShape3D_dwl4o") shape = SubResource("SphereShape3D_dwl4o")
[node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"] [node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"]

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://fal1ond30jey"] [gd_scene load_steps=5 format=3 uid="uid://fal1ond30jey"]
[ext_resource type="Script" path="res://scripts/units/components/gathering.gd" id="1_ciwtf"] [ext_resource type="Script" path="res://scripts/units/components/gathering.gd" id="1_ciwtf"]
[ext_resource type="Material" uid="uid://jkh5iskawwry" path="res://resources/materials/indicators/gathering_radius_mat.tres" id="2_r26em"] [ext_resource type="Material" uid="uid://jkh5iskawwry" path="res://resources/materials/indicators/gathering_radius_mat.tres" id="2_r26em"]
[ext_resource type="Script" path="res://scripts/audio_stream_player_polyphonic.gd" id="4_alybx"]
[sub_resource type="QuadMesh" id="QuadMesh_ks8es"] [sub_resource type="QuadMesh" id="QuadMesh_ks8es"]
material = ExtResource("2_r26em") material = ExtResource("2_r26em")
@@ -20,3 +21,6 @@ script = ExtResource("1_ciwtf")
cast_shadow = 0 cast_shadow = 0
mesh = SubResource("QuadMesh_ks8es") mesh = SubResource("QuadMesh_ks8es")
skeleton = NodePath("../..") skeleton = NodePath("../..")
[node name="AudioStreamPlayerPolyphonic" type="AudioStreamPlayer3D" parent="."]
script = ExtResource("4_alybx")

View File

@@ -0,0 +1,23 @@
extends AudioStreamPlayer3D
class_name AudioStreamPlayerPolyphonic
var playback: AudioStreamPlaybackPolyphonic
func _ready() -> void:
stream = AudioStreamPolyphonic.new()
play()
playback = get_stream_playback()
func play_polyphonic(
new_stream: AudioStream,
from_offset: float = 0,
new_volume_db: float = 0,
new_pitch_scale: float = 1.0,
) -> void:
playback.play_stream(
new_stream,
from_offset,
new_volume_db,
new_pitch_scale,
)