Any ideas on syncing playback to an in-game timer?

I have visual effects that happen in regular intervals according to an in-game timer, and I want the music playing through FMOD to have some ornamentation coinciding with the visual effects. So I need the events timeline position to match match the value of the in-game timer float with a margin of error low enough that they will be perceived as synced.

Any ideas on how I can do this? I would prefer a blueprint solution, but I can do it through C++ if there’s no other way.

You can use timeline callbacks in blueprints that can be used to trigger other behavior.

FMODAudioComponent::GetTimelinePosition and FMODAudioComponent::SetTimelinePosition are also available in blueprints, these allow you to get the current timeline position of an Event and change it.

I ended up with a solution where I use the FFModEventInstance C++ equivalent of those functions, but there seems to be a slight delay. If I set the timeline position to for example 2000, then the frame at which the playing event jumps to the 2 second mark happens enough milliseconds after the frame I called the setTimelinePosition to be perceptible.

Is there any way to fix this? For example some way to record the millisecond difference between setTimelinePositions call and execution to offset the timeline position by that amount?

SetTimelinePosition will have a random delay between when it is called and the command executes, this is because it is asynchronous and will trigger at the next Studio Update and will also be subject to scheduling delays for the mixer.

You could instead use a parameter to adjust the playback position, to do this you can move the instruments onto the parameter timeline. There is roughly 50-60ms of latency from the Update after the parameter value has been set.