added music player for all your music needs
rn it only plays bach but its good so yeah
This commit is contained in:
parent
e7aec1ae28
commit
57e94d0a8c
20 changed files with 191 additions and 31 deletions
|
|
@ -542,6 +542,7 @@ class Soundsource extends SpatialAudio3D:
|
|||
|
||||
|
||||
func update_run():
|
||||
if player_camera:
|
||||
distance_to_player = global_position.distance_to(player_camera.global_position)
|
||||
|
||||
# only update delay when moved >5m since last update
|
||||
|
|
@ -912,6 +913,7 @@ class Soundplayer extends SpatialAudio3D:
|
|||
func update_effect_params():
|
||||
# update distance vars
|
||||
distance_to_soundsource = global_position.distance_to(soundsource.global_position)
|
||||
if player_camera:
|
||||
distance_to_player = global_position.distance_to(player_camera.global_position)
|
||||
|
||||
# occlusion
|
||||
|
|
@ -964,6 +966,7 @@ class Soundplayer extends SpatialAudio3D:
|
|||
|
||||
func calculate_occlusion_lowpass():
|
||||
var limited_distance_to_player = clamp(distance_to_player, 0, max_raycast_distance)
|
||||
if player_camera:
|
||||
occlusion_raycast.target_position = global_position.direction_to(player_camera.global_position) * max_raycast_distance * 10
|
||||
|
||||
var _cutoff = 20500
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/Bach_ Toccata and Fugue in D Minor, BWV 565.m
|
|||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=3.5
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
|
|
|||
|
|
@ -247,6 +247,8 @@ func _process(_delta: float) -> void:
|
|||
var hit_object = cursor_raycast.get_collider()
|
||||
if hit_object is PickupableItem:
|
||||
_add_item(hit_object)
|
||||
elif hit_object is Button3D:
|
||||
hit_object.press()
|
||||
else:
|
||||
if inventory[selected_item] != null:
|
||||
use_active_item()
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ func _ready() -> void:
|
|||
|
||||
stamina_component.stamina_changed.connect(ui.set_stamina)
|
||||
|
||||
SignalSniffer.watch(stamina_component)
|
||||
|
||||
# TODO: why is it always called on every frame?????
|
||||
|
||||
flashlight_component.flashlight_charge_changed.connect(ui.set_flashlight)
|
||||
flashlight_component.flashlight_toggled.connect(\
|
||||
func (success):\
|
||||
|
|
@ -72,7 +68,16 @@ func _ready() -> void:
|
|||
stamina_component.run(false))
|
||||
movement_component.state_changed.connect(player_state.handle_state_change)
|
||||
|
||||
|
||||
SignalSniffer.watch(stamina_component)
|
||||
SignalSniffer.watch(flashlight_component)
|
||||
SignalSniffer.watch(hotbar_component)
|
||||
SignalSniffer.watch(movement_component)
|
||||
SignalSniffer.watch(input_controller)
|
||||
SignalSniffer.watch(procedural_animator)
|
||||
SignalSniffer.watch(sound_controller)
|
||||
SignalSniffer.watch(player_state)
|
||||
SignalSniffer.watch(inventory_component)
|
||||
|
||||
#temporary so i can prototype
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -132,11 +132,13 @@ script = ExtResource("62_jbx34")
|
|||
reverb_volume_db = -12.0
|
||||
reverb_fadeintime = -1.0
|
||||
reverb_fadeouttime = -1.0
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="HeadTexture" type="AudioStreamPlayer3D" parent="CameraPivot/Head" unique_id=732916843]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("62_jbx34")
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="CameraPivot" unique_id=303347613]
|
||||
|
|
@ -250,6 +252,7 @@ script = ExtResource("62_jbx34")
|
|||
reverb_volume_db = -12.0
|
||||
reverb_fadeintime = -1.0
|
||||
reverb_fadeouttime = -1.0
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="LeftFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/LeftFoot" unique_id=1541799094]
|
||||
|
|
@ -258,6 +261,7 @@ script = ExtResource("62_jbx34")
|
|||
reverb_volume_db = -12.0
|
||||
reverb_fadeintime = -1.0
|
||||
reverb_fadeouttime = -1.0
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="RightFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1964632523]
|
||||
|
|
@ -267,6 +271,7 @@ script = ExtResource("62_jbx34")
|
|||
reverb_volume_db = -12.0
|
||||
reverb_fadeintime = -1.0
|
||||
reverb_fadeouttime = -1.0
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="RightFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/RightFoot" unique_id=370583799]
|
||||
|
|
@ -275,6 +280,7 @@ script = ExtResource("62_jbx34")
|
|||
reverb_volume_db = -12.0
|
||||
reverb_fadeintime = -1.0
|
||||
reverb_fadeouttime = -1.0
|
||||
audiophysics_ticks = 30
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="Wind" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1950929206]
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ func _on_action_finder_body_entered(body: Node3D) -> void:
|
|||
prompt.change_text("[LMB] to grab")
|
||||
elif body is PickupableItem:
|
||||
prompt.change_text("[R] to pick up")
|
||||
elif body is Button3D:
|
||||
prompt.change_text("[R] to use")
|
||||
else:
|
||||
return
|
||||
action_panel_body = body
|
||||
|
|
|
|||
9
entities/usable/button/button.gd
Normal file
9
entities/usable/button/button.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class_name Button3D extends StaticBody3D
|
||||
|
||||
@onready var animation_player: AnimationPlayer = %AnimationPlayer
|
||||
|
||||
signal pressed
|
||||
|
||||
func press():
|
||||
animation_player.play("pressed")
|
||||
pressed.emit()
|
||||
1
entities/usable/button/button.gd.uid
Normal file
1
entities/usable/button/button.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d0n5sjpvtitix
|
||||
69
entities/usable/button/button.tscn
Normal file
69
entities/usable/button/button.tscn
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
[gd_scene format=3 uid="uid://cbpl3s326ok8d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0n5sjpvtitix" path="res://entities/usable/button/button.gd" id="1_r4dn2"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_b5l5s"]
|
||||
size = Vector3(1, 1, 0.36279297)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_b5l5s"]
|
||||
top_radius = 0.25927734
|
||||
bottom_radius = 0.25927734
|
||||
height = 0.12780762
|
||||
|
||||
[sub_resource type="Animation" id="Animation_r4krq"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MeshInstance3D2:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -0.0034615695, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_friup"]
|
||||
resource_name = "pressed"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MeshInstance3D2:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.06, 0.26, 0.39),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 0.124999836),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -0.0034615695, 0), Vector3(0, -0.0034615695, -0.013730846), Vector3(0, -0.0034615695, -0.013730846), Vector3(0, -0.003, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_cd38i"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_r4krq"),
|
||||
&"pressed": SubResource("Animation_friup")
|
||||
}
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_b5l5s"]
|
||||
size = Vector3(0.1, 0.1, 0.1)
|
||||
|
||||
[node name="Button" type="StaticBody3D" unique_id=1942355311]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
|
||||
script = ExtResource("1_r4dn2")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=192699806]
|
||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, -0.043018993)
|
||||
mesh = SubResource("BoxMesh_b5l5s")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="." unique_id=1753022499]
|
||||
transform = Transform3D(0.2, 0, 0, 0, -8.742278e-09, -0.2, 0, 0.2, -8.742278e-09, 0, -0.0034615695, 0)
|
||||
mesh = SubResource("CylinderMesh_b5l5s")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=587532613]
|
||||
unique_name_in_owner = true
|
||||
libraries/ = SubResource("AnimationLibrary_cd38i")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=612145148]
|
||||
shape = SubResource("BoxShape3D_b5l5s")
|
||||
17
entities/usable/music_player.gd
Normal file
17
entities/usable/music_player.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends Node3D
|
||||
|
||||
var is_playing: bool = false
|
||||
|
||||
@onready var audio_player: SpatialAudio3D = %SpatialAudio3D
|
||||
@onready var audiostream_player: AudioStreamPlayer3D = %AudioStreamPlayer3D
|
||||
|
||||
func toggle():
|
||||
is_playing = !is_playing
|
||||
if is_playing:
|
||||
audio_player.do_play()
|
||||
else:
|
||||
audio_player.do_stop()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
%Button.pressed.connect(toggle)
|
||||
1
entities/usable/music_player.gd.uid
Normal file
1
entities/usable/music_player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dw22i7cf5ekjx
|
||||
49
entities/usable/music_player.tscn
Normal file
49
entities/usable/music_player.tscn
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
[gd_scene format=3 uid="uid://clr8dvbm56jn8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dw22i7cf5ekjx" path="res://entities/usable/music_player.gd" id="1_johh1"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbpl3s326ok8d" path="res://entities/usable/button/button.tscn" id="1_t1vpp"]
|
||||
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="2_gor86"]
|
||||
[ext_resource type="AudioStream" uid="uid://b14wn4nntykxv" path="res://assets/sounds/music/Bach_ Toccata and Fugue in D Minor, BWV 565.mp3" id="3_rf3au"]
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_b5l5s"]
|
||||
top_radius = 0.025390625
|
||||
bottom_radius = 0.025390625
|
||||
|
||||
[sub_resource type="Curve" id="Curve_60a4j"]
|
||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_b5l5s"]
|
||||
radius = 0.1
|
||||
radial_steps = 14
|
||||
section_length = 0.1
|
||||
curve = SubResource("Curve_60a4j")
|
||||
|
||||
[node name="MusicPlayer" type="Node3D" unique_id=1866568806]
|
||||
script = ExtResource("1_johh1")
|
||||
|
||||
[node name="Button" parent="." unique_id=1942355311 instance=ExtResource("1_t1vpp")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1565274282]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.08234948)
|
||||
mesh = SubResource("CylinderMesh_b5l5s")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="." unique_id=1532772581]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 1.9501299, -0.08872458)
|
||||
mesh = SubResource("TubeTrailMesh_b5l5s")
|
||||
|
||||
[node name="SpatialAudio3D" type="AudioStreamPlayer3D" parent="." unique_id=1544705708]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.953211, 0.26459026)
|
||||
stream = ExtResource("3_rf3au")
|
||||
script = ExtResource("2_gor86")
|
||||
occlusion_lp_cutoff = 300
|
||||
collision_mask = 17
|
||||
reverb_raycast_count = 8
|
||||
debug = true
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="." unique_id=602010304]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("3_rf3au")
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://cr58irln78feo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ltgcsertsux7" path="res://entities/usable/stamina_recharge_item.gd" id="1_gy8nx"]
|
||||
[ext_resource type="Script" uid="uid://ltgcsertsux7" path="res://entities/usable_items/stamina_recharge_item.gd" id="1_gy8nx"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gy8nx"]
|
||||
albedo_color = Color(0.41262913, 0.69107723, 7.70092e-07, 1)
|
||||
|
|
@ -3,12 +3,11 @@
|
|||
[ext_resource type="PackedScene" uid="uid://dvw51mhd42wg7" path="res://entities/backpack/bakpakbruh.tscn" id="1_de016"]
|
||||
[ext_resource type="Script" uid="uid://d5aotywdqlh5" path="res://entities/grabbable_base/grabbable_item.gd" id="1_l7v2h"]
|
||||
[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://entities/player/player.tscn" id="1_s8b7j"]
|
||||
[ext_resource type="AudioStream" uid="uid://b6wlbiittcu48" path="res://assets/sounds/ambiance/harmonika-paulstretched.mp3" id="3_mtlx8"]
|
||||
[ext_resource type="PackedScene" uid="uid://don2g5auhwbl8" path="res://entities/pickupable/test_object_pickupable.tscn" id="3_omlgy"]
|
||||
[ext_resource type="PackedScene" uid="uid://codt2h7ojcsae" path="res://entities/pickupable/test_object_pickupable_2.tscn" id="4_8r7k8"]
|
||||
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="4_yb1w3"]
|
||||
[ext_resource type="PackedScene" uid="uid://wvsly1kbdney" path="res://entities/pocket/pocket.tscn" id="5_8r7k8"]
|
||||
[ext_resource type="PackedScene" uid="uid://cr58irln78feo" path="res://entities/usable/stamina_recharge_item.tscn" id="9_hupuo"]
|
||||
[ext_resource type="PackedScene" uid="uid://cr58irln78feo" path="res://entities/usable_items/stamina_recharge_item.tscn" id="9_hupuo"]
|
||||
[ext_resource type="PackedScene" uid="uid://clr8dvbm56jn8" path="res://entities/usable/music_player.tscn" id="10_13hof"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_g4v7s"]
|
||||
|
||||
|
|
@ -93,21 +92,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.3125359, 1.137004)
|
|||
[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1317582521]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2949467, -3.755646)
|
||||
|
||||
[node name="SpatialAudio3D" type="AudioStreamPlayer3D" parent="." unique_id=351573539]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.887349, 4.01754, -1.2293816)
|
||||
stream = ExtResource("3_mtlx8")
|
||||
volume_db = -8.235
|
||||
autoplay = true
|
||||
max_distance = 1927.53
|
||||
script = ExtResource("4_yb1w3")
|
||||
occlusion_fadetime = 0.0
|
||||
bass_proximity = 0
|
||||
max_raycast_distance = 30
|
||||
roomsize_multiplicator = 2.0
|
||||
prox_reduction = 16.0
|
||||
debug = true
|
||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1656249102]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.053528, 0, 9.284716)
|
||||
|
||||
|
|
@ -146,3 +130,6 @@ camera_attributes = SubResource("CameraAttributesPractical_60a4j")
|
|||
|
||||
[node name="UsableBase" parent="." unique_id=1189819781 instance=ExtResource("9_hupuo")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.8267124, 0.65320015, -0.25214243)
|
||||
|
||||
[node name="MusicPlayer" parent="." unique_id=1866568806 instance=ExtResource("10_13hof")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.569429, 1.810069, 2.4010668)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
[gd_scene format=3 uid="uid://dpipi1pttxrcp"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_pxn7n"]
|
||||
size = Vector3(3, 3, 0.2)
|
||||
size = Vector3(3, 3, 0.5260132)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_dikcp"]
|
||||
size = Vector3(3, 3, 0.1)
|
||||
size = Vector3(3, 3, 0.5432373)
|
||||
|
||||
[node name="WallBase" type="StaticBody3D" unique_id=1490575404]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1929329994]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.042295262)
|
||||
shape = SubResource("BoxShape3D_pxn7n")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D" unique_id=460229788]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.035827667)
|
||||
mesh = SubResource("BoxMesh_dikcp")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://dpipi1pttxrcp" path="res://maps/procedural_map_parts_ver_premade/blocks/wall_base.tscn" id="1_3yqjc"]
|
||||
[ext_resource type="Script" uid="uid://dvmuhlmqeknv2" path="res://maps/procedural_map_parts_ver_premade/parts/big_part.gd" id="1_sdg7d"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyh7k0iqmoa1s" path="res://maps/procedural_map_parts_ver_premade/blocks/wall_hole_base.tscn" id="2_1mbjt"]
|
||||
[ext_resource type="PackedScene" uid="uid://clr8dvbm56jn8" path="res://entities/usable/music_player.tscn" id="4_adfox"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_b5l5s"]
|
||||
size = Vector3(36, 0.1, 36)
|
||||
|
|
@ -216,3 +217,9 @@ unique_name_in_owner = true
|
|||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Volume" unique_id=275812274]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0)
|
||||
shape = SubResource("BoxShape3D_sdg7d")
|
||||
|
||||
[node name="MusicPlayer" parent="." unique_id=1866568806 instance=ExtResource("4_adfox")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -17.367523, 1.2723811, -4.501629)
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="MusicPlayer" unique_id=1888250769]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6807523, 0.5101266, 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue