Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Audio FMOD: how to get position of event playing via Event Emitter on an obj

Discussion in 'Audio & Video' started by wheatgrinder, Jul 6, 2018.

  1. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    I cant figure out how to get the "current" position of a playing FMOD event.

    I understand from docs that I can use Studio.EventInstance.getTimelinePosition on a EventInstance, but I cant seem to figure out how to get the Event Instance from the event playing via the Event Emitter?

    Should I just dump having the EventEmiiter's and just create events via code?
     
  2. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    Rolled my own solution:
    Code (CSharp):
    1.  
    2. int GetEventPos_FromEventEmitter(FMODUnity.StudioEventEmitter _eventEmitter)
    3.     {
    4.         FMOD.RESULT res;
    5.         int _eventPos;
    6.         EventInstance[] _events;
    7.         EventInstance eventInstance;
    8.         res = FMODUnity.RuntimeManager.GetEventDescription(_eventEmitter.Event).getInstanceList(out _events); // .Events;
    9.         eventInstance = _events[0]; //return the first instance of the event
    10.         res = eventInstance.getTimelinePosition(out _eventPos);
    11.         return _eventPos;
    12.     }
    13.  
    invoked thus
    Code (CSharp):
    1. int eventPos = GetEventPos_FromEventEmitter(myGameObject.GetComponent<FMODUnity.StudioEventEmitter>());