Answered
0
0

I have Fmod Studio integrated with Unity and I’m now trying to play an Fmod Studio Event on an animation’s keyframe.

On the Animation’s timeline I set a keyframe to enable the following script:

using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class AnimationPlayFmodSound : MonoBehaviour {

    void OnEnable () {
        FMOD_StudioSystem.instance.PlayOneShot ("event:/Resources/FX/fx_column_effect", transform.position);        
    }
}

I thought it should play only when the script is enabled, but apparently the event plays as soon as I start the game (before the animation occurs). What am I doing wrong here?

  • You must to post comments
Best Answer
0
0

This works for me:

using UnityEngine;
using System.Collections;

public class SoundEvent : MonoBehaviour {

public FMODAsset A_EventSound;

public void PlaySound (FMODAsset A_EventSound) {
        if(A_EventSound != null)
        {
            FMOD_StudioSystem.instance.PlayOneShot(A_EventSound, transform.position);
        }
        else
        {
            Debug.LogError("EventSound is null");
        }

    }
}

The script is attached to the root of the GameObject (model).

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.