add a custom audio listener
This commit is contained in:
@@ -196,7 +196,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -50.9454, -8.10623e-06, -60.0
|
|||||||
gizmo_extents = 4.7
|
gizmo_extents = 4.7
|
||||||
script = ExtResource("3_vkmt5")
|
script = ExtResource("3_vkmt5")
|
||||||
what = 1
|
what = 1
|
||||||
amount = 30
|
amount = 0
|
||||||
|
|
||||||
[node name="UI" type="Node" parent="."]
|
[node name="UI" type="Node" parent="."]
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ fov = 37.8493
|
|||||||
script = ExtResource("1_gnxhh")
|
script = ExtResource("1_gnxhh")
|
||||||
|
|
||||||
[node name="AudioListener3D" type="AudioListener3D" parent="MainCamera"]
|
[node name="AudioListener3D" type="AudioListener3D" parent="MainCamera"]
|
||||||
current = true
|
top_level = true
|
||||||
|
|
||||||
[node name="AmbientAudio" type="AudioStreamPlayer" parent="."]
|
[node name="AmbientAudio" type="AudioStreamPlayer" parent="."]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
|
|||||||
@@ -53,11 +53,14 @@ var state: CameraState = CameraState.FREE
|
|||||||
var window_out_of_focus: bool = false
|
var window_out_of_focus: bool = false
|
||||||
|
|
||||||
@onready var attrs: CameraAttributesPractical = attributes
|
@onready var attrs: CameraAttributesPractical = attributes
|
||||||
|
@onready var listener: AudioListener3D = $AudioListener3D
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
assert(attrs != null, "attrs missing!")
|
assert(attrs != null, "attrs missing!")
|
||||||
|
assert(listener != null, "listener missing!")
|
||||||
target_position = StaticNodesManager.player_anthill.global_position
|
target_position = StaticNodesManager.player_anthill.global_position
|
||||||
|
listener.make_current()
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
@@ -67,17 +70,20 @@ func _process(delta: float) -> void:
|
|||||||
zoom_value = lerpf(zoom_value, zoom_unsmoothed, delta * ZOOM_DAMP)
|
zoom_value = lerpf(zoom_value, zoom_unsmoothed, delta * ZOOM_DAMP)
|
||||||
|
|
||||||
fov = lerpf(zoom_in_fov, zoom_out_fov, zoom_value)
|
fov = lerpf(zoom_in_fov, zoom_out_fov, zoom_value)
|
||||||
rotation.x = lerpf(zoom_in_angle, zoom_out_angle, zoom_value)
|
global_rotation.x = lerpf(zoom_in_angle, zoom_out_angle, zoom_value)
|
||||||
var distance: float = lerpf(zoom_in_distance, zoom_out_distance, zoom_value)
|
var distance: float = lerpf(zoom_in_distance, zoom_out_distance, zoom_value)
|
||||||
|
|
||||||
var offset_direction := Vector3.BACK.rotated(Vector3.RIGHT, rotation.x)
|
var offset_direction := Vector3.BACK.rotated(Vector3.RIGHT, global_rotation.x)
|
||||||
var offset := offset_direction * distance
|
var offset := offset_direction * distance
|
||||||
global_position = target_position + offset
|
global_position = target_position + offset
|
||||||
|
listener.global_position = target_position + (Vector3.UP * distance)
|
||||||
|
listener.global_rotation = global_rotation
|
||||||
|
|
||||||
_handle_dof()
|
_handle_dof()
|
||||||
_handle_advance_anim_step()
|
_handle_advance_anim_step()
|
||||||
|
|
||||||
DebugManager.marker(target_position, 0.05)
|
DebugManager.marker(target_position, 0.05)
|
||||||
|
DebugManager.marker(listener.global_position, 0.05, Color.GREEN)
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
@@ -180,7 +186,7 @@ func _handle_movement(delta: float) -> void:
|
|||||||
|
|
||||||
var direction := (
|
var direction := (
|
||||||
Vector3(move_input.x, 0, move_input.y)
|
Vector3(move_input.x, 0, move_input.y)
|
||||||
.rotated(Vector3.UP, rotation.y)
|
.rotated(Vector3.UP, global_rotation.y)
|
||||||
)
|
)
|
||||||
|
|
||||||
var speed: float = lerpf(zoom_in_speed, zoom_out_speed, zoom_value)
|
var speed: float = lerpf(zoom_in_speed, zoom_out_speed, zoom_value)
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ func _handle_honeydew_spawn(delta: float) -> void:
|
|||||||
if honeydew_spawn_timer >= 0:
|
if honeydew_spawn_timer >= 0:
|
||||||
honeydew_spawn_timer -= delta
|
honeydew_spawn_timer -= delta
|
||||||
return
|
return
|
||||||
|
|
||||||
|
audio_player.play_sound(SoundManager.pop())
|
||||||
var new_honeydew := honeydew_scene.instantiate() as Honeydew
|
var new_honeydew := honeydew_scene.instantiate() as Honeydew
|
||||||
new_honeydew.set_aphid(self)
|
new_honeydew.set_aphid(self)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user