If you want to be able to pause your game’s music and then unpause it again later without starting it over from the beginning, and also want to use this method of selecting which track to play, there’s a way to do it.
You’ll need to create two instances of the parent event that uses a parameter to select which music track should play; I’ll call these “the A instance” and “the B instance.” Pause the B instance (using Studio::EventInstance::setPaused immediately upon starting it, and allow the A instance to play.
When you want to pause the music that’s currently playing and begin playing a different track, set the parameter of the B instance to the parameter value corresponding to the new music you want to play, then pause the A instance and unpause the B instance (again by using Studio::EventInstance::setPaused). This will cause the B instance to begin playing the new track.
When you want to stop playing the new track and resume the old track, pause the B instance and unpause the A instance. This will cause the A instance to resume playing from the point it was paused at.
Paused event instances are automatically virtualized, and thus consume only a negligible amount of resources.
Yes and no. In order to call EventInstance::setTimelinePosition on an event instance, that instance must exist, and therefore must have been created. However, it is not necessary to create a new instance purely so that you can call EventInstance::setTimelinePosition on it; if an instance exists already, you could call it on that instance.
In any case, the method I described in that other thread was for starting music that had not previously been playing in the player’s local instance of the game. In your case, you want to resume playing music that had already been playing before being paused, which makes pausing and unpausing the event instance more appropriate than using EventInstance::setTimelinePosition on a new instance of the event.
No. It is also possible to set the timeline position of an event by using logic markers; and every instrument has a “start offset” property that determines how far through the asset the asset begins playing from when that instrument is triggered, making it possible to start from part-way through an asset without using the timeline playback position at all.
That being said, none of these methods will be necessary if you pause and unpause the event instance as I suggested above.
Yes. The method I described above should work.
No. It is not possible to get or set the timeline playback position of an event instance spawned by an event instrument or command instrument. If you want to get or set the timeline playback position of an event instance, the event instance must be spawned by your game’s code.
Fortunately, the method of pausing and unpausing events that I described above does not require you to get or set the timeline playback position of any event instance.
Yes and no.
Whenever an event instrument is triggered, it spawns a new instance of the event it references. Each such new event instance is completely independent of any other instance of that event that may have been spawned previously.
When an event instrument is untriggered, it may or may not destroy any currently-playing instance of the event instance associated with that instrument. Whether it does depends on the instrument’s settings, and on the content of the associated event.