Skip to content

SpatialReflectionNavigationAgent3D

Carries a SpatialAudioPlayer3D's sound around walls, so you hear it from the doorway or corner it would really reach you through. See Sound around corners for setup.

Inherits: Node3D
Script: addons/spatial_audio_extended/spatial_reflection_navigation_agent_3d.gd

Enums

Enum Values
RouteState DIRECT the listener can see the source. ROUTED the sound comes around one or more corners. NO_ROUTE no open route, so the player falls back to plain occlusion

Routing

Property Default Description
routing_enabled on Turns routing on. Off, the player sits on the agent and only uses occlusion
audio_player none The player to move. Empty uses the first SpatialAudioPlayer3D child
fill_range 100 % How much of the player's audible range (inner radius plus falloff distance) the cells fill. The fill never goes past where the sound can be heard
fill_distance read only How far the fill reaches in metres, worked out from fill_range
cell_size 0.5 m Size of each cell. Smaller cells fit through narrower gaps but take longer to fill
collision_mask 1 Physics layers that block sound

Sound

Property Default Description
smoothing 0.15 s How long a switch to a new corner, or between direct and routed, takes to blend. Your own movement is never delayed
bend_loss_db 3 dB Volume lost for every 90 degrees the sound bends
bend_lowpass_hz 4000 Hz Lowpass cutoff after a 90 degree bend. Sharper bends sound darker. 20000 turns it off

Updates

Property Default Description
watch_for_changes on Rechecks cells in the background, and straight away around any body that moves, so doors and moving walls change the routes
frame_budget_ms 2 ms Time per frame the agent may spend filling and rechecking cells

Debug

Property Default Description
debug_draw_route off Draws the route and where the player sits. Blue for direct, green for routed, red for no route
debug_draw_cells off Draws every reached cell, coloured by route length, and rings at the fill range
debug_toggle_route_key F4 Draws or hides the route while the player's display_debug_info is on
debug_toggle_cells_key F5 Draws or hides the cells while the player's display_debug_info is on

Methods

Method Does
rebuild() Throws away every cell and fills the space again. Use after loading or moving large parts of the level
get_route_state() -> RouteState Whether the sound is direct, routed or has no route
get_current_path_world() -> PackedVector3Array The route from the source to the listener, corners included
get_route_length() -> float Distance the sound travels to the listener, around corners
get_bend_degrees() -> float Total angle the sound bends on the way
get_reached_cell_count() -> int Open cells the last fill reached
has_valid_path() -> bool True unless the state is NO_ROUTE
is_direct_path() -> bool True when the state is DIRECT

force_recompute() and get_path_length() still work, as other names for rebuild() and get_route_length().

Signals

Signal Emitted when
path_updated(path_world: PackedVector3Array, direct_path: bool) The route changes shape: a new corner, or a switch between direct and routed
path_failed(origin_world: Vector3, target_world: Vector3) The listener can't see the source and no route reaches them
audio_proxy_position_updated(proxy_world: Vector3) Every physics frame, with the player's new position
graph_rebuilt(point_count: int) A fill of the space finishes. point_count is the reached cell count

In the editor

Select the agent or its player to see how far the cells will fill: a green ring at the fill range, and an orange ring at the player's audible range when the fill stops short of it.

Warnings

The scene tree warns when no SpatialAudioPlayer3D is set or found as a child.