Godot Version
4.3.stable
Question
I have a single AudioStreamPolyphonic resource that I set as the stream of my target AudioStreamPlayer. The polyphony value is set to 64.
I use the following script to play streams to it
extends Node
class_name EntitySFX
@export var BlockSound:AudioStream
@export var DeathSound:AudioStream
var asp:AudioStreamPlaybackPolyphonic;
var audioplayer:AudioStreamPlayer;
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
audioplayer = $"../AudioStreamPlayer"
audioplayer.play()
asp = audioplayer.get_stream_playback()
pass # Replace with function body.
func _on_block(_damage: float) -> void:
if BlockSound:
asp.play_stream(BlockSound,0,-3,randf_range(0.9,1.0))
func _on_death(_damageable: Damageable) -> void:
if DeathSound:
asp.play_stream(DeathSound,0,5)
Multiple objects use this script to play their soundfx, but for whatever reason the audio is cut. The first stream sounds ok is but cuts off too soon most of the times.
The DeathSound won’t even play eventhough it does print a valid return ID
One thing I noticed is that most Id’s are low numbers with the ocasional high ID like 8589934595
or 4294967299
etc, for those i notice it hard cuts the sound.
Am I missing something? Is there a reason why this is happening?
Here it is in action ( not allowed to upload attachments yet ):