Hey team, looking for help with a timeline issue. First I’ll explain how I’m using the timeline, then I’ll explain the issue.
How I use the timeline: in my game I have a moving platform blueprint, which consists of a static mesh (currently set to the default unreal Cube mesh). The mesh location is updated on a timeline, moving it from the StartLocation to the TargetLocation. The level designer can set the TargetLocation in the Details panel after dragging the blueprint into the level
On BeginPlay, I set the start location and the play rate (the level designer can control the speed of the platform), and ultimately calls a custom event Start. This checks if we have any Offset (the level designer can add an offset time so that the platform waits for a moment before beginning its timeline), and if so, calls SetTimerByEvent with Time == Offset.
After the Offset time expires, we call Play which goes into a flipflop. The flipflop A goes into a Timeline’s Play pin. The flipflop B goes into the Timeline’s Reverse pin. When the timeline finishes, we call a custom event Pause, which checks if the level designer added any Delay (to stop the platform after each cycle). This allows the player to hop on the platform when it reaches the target location, rather than it immediately returning.
All of this is working great, except for one major pitfall
The issue: When my character is riding on the platform, there is a slight unpredictable extra delay before the timeline starts again. If I have two moving platforms side by side with the same settings, if I ride one of the platforms, it quickly becomes out of sync with the other one.
Some observations:
- The platform still travels at the same speed, the desync only happens after we reach TargetLocation. We reach TargetLocation at the same time as the other platform. The other platform starts returning to StartLocation perfectly on time, while the platform I’m riding on takes slightly longer (again with the exact same settings)
- The platforms are perfectly in sync if I’m not standing on them
- If there is no delay between cycles (i.e the level designer left it at 0), then there is no desync, even if I’m standing on a platform. In this case we bypass the Set Timer By Event node and we call Play right away
- This is not affected by networking or multiplayer scenarios. The same behaviour happens for server and client, and when there is only one player
- I’ve tried using Tick to correct the platform’s position based on GetGameTimeInSeconds It must have something to do with the extra calculations happening when the player is colliding with the platform.
The attached video more or less shows the issue. In the video, I alt+tab away from unreal to simulate low frame rate, to show how the issue is exacerbated at low frame rate
It is worth pointing out here that if there is no Delay configured between cycles, and I’m riding the platform, there is no desync at all – This supports the idea that the issue lies somewhere within the SetTimerByEvent taking a little bit longer to process
I should mention that I’ve tried using SetTimerByEvent, I’ve tried a Delay node, even another Timeline to process the between-cycles delay, and a few different approaches with Event Tick, but all approaches resulted in the exact same things as evidenced in my video above
Here’s a UEPasteBin for my blueprint: Moving Platform timeline posted by anonymous | blueprintUE | PasteBin For Unreal Engine
Incase that doesn’t work, here’s an image:
Here’s the video: