AcousticBody¶
Gives a wall, floor or prop an AcousticMaterial. Add it as a direct child of the body the rays hit.
Inherits: Node
Script: addons/spatial_audio_extended/acoustic_body.gd
Parents it works on¶
| Parent | For |
|---|---|
StaticBody3D |
Walls, floors, ceilings and fixed props |
RigidBody3D |
Crates, doors and anything that moves |
CharacterBody3D |
Players and NPCs |
Area3D |
Volumes the rays should treat as a surface |
CSGShape3D |
CSG boxes, spheres and the rest, with Use Collision on |
It has to be a direct child. Deeper in the tree, it isn't found. See Surfaces and materials for setup.
Properties¶
| Property | Type | Description |
|---|---|---|
acoustic_material |
AcousticMaterial |
How this surface absorbs and passes sound. Without one, the player uses its fallback_transmission |
Static methods¶
static find_on(node: Node) -> AcousticBody¶
Returns the first AcousticBody child of node, or null.
static find_for_collider(collider: Node) -> AcousticBody¶
Returns the AcousticBody for whatever a ray hit. It checks the collider first, then its parent if that's a CSG
shape, because rays hit the hidden StaticBody3D inside a CSG shape.
var hit := get_world_3d().direct_space_state.intersect_ray(query)
if not hit.is_empty():
var body := AcousticBody.find_for_collider(hit.collider)
if body and body.acoustic_material:
print("Mid absorption: ", body.acoustic_material.absorption_mid)
Warnings¶
The scene tree warns when the parent isn't a physics body or CSG shape, when a CSG parent has Use Collision
off or sits in a CSGCombiner3D, when the parent has more than one AcousticBody, and when no material is set.