Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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>());