HammeriteAudioReceiver3D
Audio. Inherits Node3D
Something in the world that can hear, as a node. Attach one to a guard.
It says which kinds of sound it cares about and how faint a sound it will still notice, and emits sound_heard when one arrives above that threshold. Everything between - working out whether the sound could reach here at all, by what route, and how much of it survived the trip - is the audio graph's job, and the listener never sees it.
Nothing happens for types this listener has not asked for. That is the whole cost model: a footstep in a level where nothing listens for footsteps does not get propagated, or even measured.
@onready var _ears: HammeriteAudioReceiver3D = $Hearing func _ready() -> void: _ears.heard_types = [&"footstep", &"glass_break"] _ears.sound_heard.connect(_on_sound_heard)
func _on_sound_heard(event: HammeriteAudioSoundEvent) -> void: # Go and look where it SEEMED to come from, not where it actually was. investigate(event.apparent_position) Emitted when a sound of a subscribed type arrives at or above threshold_db.
Native since 2.0 (#269): it registers on entering the tree, again once ready - after a script's own _ready, which is where a subclass sets its types - and goes on leaving it, from its notifications, so a script on top keeps its own _enter_tree, _ready and _exit_tree and calls no super() in them.
Properties
| Type | Name | Default |
|---|---|---|
bool | enabled | true |
StringName[] | heard_types | [] |
bool | ignore_own_sounds | true |
Node | own_sounds_node | |
float | threshold_db | 20.0 |
Methods
| Returns | Method |
|---|---|
bool | add_heard_type(type: StringName) |
float | ear_gain_db() const |
String | ear_portal() const |
bool | hears_type(type: StringName) const |
bool | is_own_sound(emitter: Node) const |
void | press_ear_to_portal(portal_name: String, gain_db: float) |
bool | remove_heard_type(type: StringName) |
void | take_ear_from_portal() |
Signals
sound_heard
signal sound_heard(event: HammeriteAudioSoundEvent)
Undocumented.
Property descriptions
enabled
var enabled: bool = true
Undocumented.
heard_types
var heard_types: StringName[] = []
Undocumented.
ignore_own_sounds
var ignore_own_sounds: bool = true
Undocumented.
own_sounds_node
var own_sounds_node: Node
Undocumented.
threshold_db
var threshold_db: float = 20.0
Undocumented.
Method descriptions
add_heard_type()
func add_heard_type(type: StringName) -> bool
Undocumented.
ear_gain_db()
func ear_gain_db() -> float
Undocumented.
ear_portal()
func ear_portal() -> String
Undocumented.
hears_type()
func hears_type(type: StringName) -> bool
Undocumented.
is_own_sound()
func is_own_sound(emitter: Node) -> bool
Undocumented.
press_ear_to_portal()
func press_ear_to_portal(portal_name: String, gain_db: float) -> void
Undocumented.
remove_heard_type()
func remove_heard_type(type: StringName) -> bool
Undocumented.
take_ear_from_portal()
func take_ear_from_portal() -> void
Undocumented.