Browse Source

Fixed GameAction not playing SFX clips

James Peret 2 years ago
parent
commit
65bb9f7762
1 changed files with 5 additions and 2 deletions
  1. 5 2
      Runtime/GameActions/PlaySFXClipGameAction.cs

+ 5 - 2
Runtime/GameActions/PlaySFXClipGameAction.cs

@@ -56,11 +56,14 @@ namespace KairoEngine.SFX.GameActions
 
         public override void Start()
         { 
+            Debug.Log("Playing sound");
             GameObject parentObj = GetVariable<GameObject>(parent, null);
+            Transform parentTransform = null;
+            if(parentObj != null) parentTransform = parentObj.transform;
             Vector3 pos = new Vector3();
             if(parentObj != null) pos = parentObj.transform.position;
-            if(librarySfxClipName != null) SoundController.EmmitSound(librarySfxClipName, pos, parentObj.transform);
-            else if(sfxClip != null) SoundController.EmmitSound(sfxClip, pos, parentObj.transform);
+            if(sfxClip != null) SoundController.EmmitSound(sfxClip, pos, parentTransform);
+            else if(!string.IsNullOrEmpty(librarySfxClipName)) SoundController.EmmitSound(librarySfxClipName, pos, parentTransform);
             _done = true;
             _started = true;
         }