HammeriteAudioEmitter3D
Audio. Inherits Node3D
A thing in the world that makes a sound, as a node.
The manager's handle API is the machinery: create a sound, hold its handle, push the position in before every play, remember to delete it. That is fine for the systems that own a sound's whole lifetime and wrong for the common case, which is "this object makes this noise when it does that". A footstep ended up as a handle created at startup, a position hand-synced on every step, and a delete nobody remembered - all of it bookkeeping about a sound that simply belongs to the player.
Add one of these as a child of whatever makes the noise, point it at a file, and call play(). It follows its own transform, so a moving source needs nothing said about it; it finds the audio manager itself, so no caller digs through HammeriteMap3D.get_runtime_data(); and it cleans up after itself when it leaves the tree.
For a noise with no object behind it - an impact at a point in space, a sound whose emitter is about to be freed - use HammeriteAudio.play_one_shot() instead.
@onready var _steps: HammeriteAudioEmitter3D = $Footsteps func _on_step() -> void: _steps.play() Emitted when a non-looping sound has played through.
Native since 2.0 (#269): its tree and frame work is done from notifications, so a script on top keeps its own _enter_tree, _ready, _process and _exit_tree and calls no super() in them.
Properties
| Type | Name | Default |
|---|---|---|
bool | autoplay | false |
bool | loop | false |
bool | propagate | true |
String | sound_file | "" |
StringName | sound_type | &"" |
float | volume_db | 0.0 |
Methods
| Returns | Method |
|---|---|
bool | is_playing() const |
void | play() |
void | stop() |
Signals
finished
signal finished()
Undocumented.
Property descriptions
autoplay
var autoplay: bool = false
Undocumented.
loop
var loop: bool = false
Undocumented.
propagate
var propagate: bool = true
Undocumented.
sound_file
var sound_file: String = ""
Undocumented.
sound_type
var sound_type: StringName = &""
Undocumented.
volume_db
var volume_db: float = 0.0
Undocumented.
Method descriptions
is_playing()
func is_playing() -> bool
Undocumented.
play()
func play() -> void
Undocumented.
stop()
func stop() -> void
Undocumented.