Skip to content

Commit a08f9d1

Browse files
committed
Fix #33: gracefully handle audiosources being destroyed
1 parent a86ea57 commit a08f9d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Source/RocketSoundEnhancement/RocketSoundEnhancement.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ private void OnPartDestroyed()
297297

298298
void LateUpdate()
299299
{
300+
// many things can destroy an audio source without us knowing about it
301+
// for example an AUDIO effect connected to ModuleAnimationGroup
302+
if (source == null)
303+
{
304+
Destroy(this);
305+
return;
306+
}
307+
300308
// the vessel object may change on decoupling etc so we can't just cache the shipEffects object
301309
part.vessel.GetComponentCached(ref shipEffects);
302310

0 commit comments

Comments
 (0)