Skip to content

Commit bae47be

Browse files
committed
Fix SoundscapeTrigger error if source or SoundFile is not valid
1 parent 96597e2 commit bae47be

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

engine/Sandbox.Engine/Scene/Components/Audio/SoundscapeTrigger.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ public LoopedSoundEntry( Soundscape.LoopedSound sound, float internalVolume, flo
317317

318318
public override void Frame( in Transform head )
319319
{
320+
if ( source == null || !source.SoundFile.IsValid() )
321+
{
322+
Finished = true;
323+
return;
324+
}
325+
320326
var targetVolume = sourceVolume * internalVolume * Volume;
321327
if ( Finished ) targetVolume = 0.0f;
322328

@@ -374,6 +380,12 @@ public override void Frame( in Transform head )
374380
if ( timeUntilNextShot > 0 )
375381
return;
376382

383+
if ( source == null || !source.SoundFile.IsValid() )
384+
{
385+
Finished = true;
386+
return;
387+
}
388+
377389
timeUntilNextShot = source.RepeatTime.GetValue();
378390

379391
handle?.Stop( 0.1f );

0 commit comments

Comments
 (0)