Made suit song less painful to listen to

This commit is contained in:
Thomas Muller 2023-10-02 20:16:42 -04:00
parent 4923f7437d
commit 1263cbac6f
2 changed files with 45 additions and 10 deletions

21
Suit.gd
View file

@ -4,14 +4,24 @@ extends Area3D
@onready @onready
var _grab_sound: AudioStreamPlayer3D = $GrabSound var _grab_sound: AudioStreamPlayer3D = $GrabSound
@onready @onready
var _voice = $VoiceOverlay var _song: AudioStreamPlayer = $Song
@onready
var _anim: AnimationPlayer = $AnimationPlayer
var _activated = false var _activated = false
func _ready(): func _ready():
_grab_sound.finished.connect(_on_sound_finished) _grab_sound.finished.connect(_on_sound_finished)
_voice.finished.connect(_on_sound_finished) _song.finished.connect(_on_sound_finished)
var animation: Animation = _anim.get_animation('fade')
var track = animation.find_track('Song:volume_db', Animation.TrackType.TYPE_BEZIER)
var time = _song.stream.get_length()
animation.length = time
animation.bezier_track_insert_key(track, time, -80, Vector2(-0.25, 0))
func _process(delta):
print(_song.volume_db)
func _on_body_entered(body): func _on_body_entered(body):
@ -20,11 +30,12 @@ func _on_body_entered(body):
if body.is_in_group('Players'): if body.is_in_group('Players'):
_activated = true _activated = true
hide() hide()
_anim.play('fade')
_grab_sound.play() _grab_sound.play()
_voice.play() _song.play()
func _on_sound_finished(): func _on_sound_finished():
# Make sure both sounds are done playing # Make sure both sounds are done playing
if not _grab_sound.playing and not _voice.playing: if not _grab_sound.playing and not _song.playing:
queue_free() queue_free()

View file

@ -1,13 +1,33 @@
[gd_scene load_steps=6 format=3 uid="uid://dsio3s1m2uinu"] [gd_scene load_steps=8 format=3 uid="uid://dsio3s1m2uinu"]
[ext_resource type="Script" path="res://Suit.gd" id="1_mbmhc"] [ext_resource type="Script" path="res://Suit.gd" id="1_mbmhc"]
[ext_resource type="AudioStream" uid="uid://dp021qbu4qpar" path="res://assets/sounds/button/button01_press.ogg" id="2_sy7ac"] [ext_resource type="AudioStream" uid="uid://dp021qbu4qpar" path="res://assets/sounds/button/button01_press.ogg" id="2_sy7ac"]
[ext_resource type="AudioStream" uid="uid://6a6ayirpiohc" path="res://assets/sounds/music/Spazzmatica Polka.mp3" id="3_5p01t"] [ext_resource type="AudioStream" uid="uid://6a6ayirpiohc" path="res://assets/sounds/music/Spazzmatica Polka.mp3" id="3_ghfbi"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_2trlk"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_2trlk"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_h8f8c"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_h8f8c"]
[sub_resource type="Animation" id="Animation_nkgx4"]
resource_name = "fade"
length = 5.0
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Song:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(0, -0.25, 0, 0.8, 0, -20, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 5)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gxgtv"]
_data = {
"fade": SubResource("Animation_nkgx4")
}
[node name="Suit" type="Area3D"] [node name="Suit" type="Area3D"]
script = ExtResource("1_mbmhc") script = ExtResource("1_mbmhc")
@ -22,8 +42,12 @@ shape = SubResource("CapsuleShape3D_h8f8c")
[node name="GrabSound" type="AudioStreamPlayer3D" parent="."] [node name="GrabSound" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("2_sy7ac") stream = ExtResource("2_sy7ac")
[node name="VoiceOverlay" type="AudioStreamPlayer3D" parent="."] [node name="Song" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_5p01t") stream = ExtResource("3_ghfbi")
volume_db = -20.0
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_gxgtv")
}
[connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_entered" from="." to="." method="_on_body_entered"]