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

**URL:** <https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165>\
**Category:** Unreal Engine\
**Created:** [October 25, 2019, 3:11pm UTC](https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165 "2019-10-25T15:11:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarsAstro](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@MarsAstro](https://qa.fmod.com/u/MarsAstro)\
**Post date:** [October 25, 2019, 3:11pm UTC](https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165/1 "2019-10-25T15:11:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 1, 2019, 3:36am UTC](https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165/2 "2019-11-01T03:36:55Z")

</div>

You can use [timeline callbacks](https://fmod.com/resources/documentation-ue4?version=2.0&page=user-guide.html#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.

---

<div class="post-metadata">

**Author:** ![MarsAstro](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@MarsAstro](https://qa.fmod.com/u/MarsAstro)\
**Post date:** [November 7, 2019, 3:38pm UTC](https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165/3 "2019-11-07T15:38:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 12, 2019, 3:28am UTC](https://qa.fmod.com/t/any-ideas-on-syncing-playback-to-an-in-game-timer/15165/4 "2019-11-12T03:28:54Z")

</div>

`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.
