Jump to content

[Solved]Syncing player movement based on RenderTickEvents with ServerTickEvents


Recommended Posts

I'm looking for ideas on what direction I should take, not necessarily a specific answer.


Long story short:


I'm managing building pre-recorded structures during server tick events and doing pre-recorded player movements during render tick events (to get smooth motion).  Although I can mostly get things synced up and consistent, the player movements are dependent on performance and get out of sync with structure building if conditions change (like when I try to record things with video capture software).


Any thoughts on how best to get the camera (player) from point A to point B in a specific amount of server ticks while still having it be smooth?


Long story long:


I made a mod which lets me record block placement and then playback the recordings.  I can adjust the playback speed, number of copies, location etc.  The playback process is handled during SeverTickEvents.  In addition to this, I am able to move the camera (the player) to and between set locations during RenderTickEvents .  The idea is to build structures while the camera moves around to set locations.


The problem is that while structure building is not dependent on performance (it's pretty consistent because it's based on server ticks) the player movement is based on performance.  I figured that I could manage with this because the results were "consistent" (given the same conditions).  However, the moment I tried to start recording the results using video capture software, the player movements and structure building quickly got out of sync.


Possible Fixes:


- I was thinking that I could time player movements based on server ticks (ex. Move player from A to B in 20 ticks) but keep track of the average number of render ticks per per server tick (based on current performance) and update the players location exactly 3 times per server tick (to accommodate 60fps recording).  For example, if there was 30 render ticks during the last server tick, I would update the player's location every 10 render ticks during the next server tick.  I'm not really sure if I can do this smoothly without judder and inconsistent movements.


- A more extreme solution (which I hope I don't have to implement) would be to try and render everything offline like some recording mods do.  I hope that there's an easier solution.


Any thoughts?  Am I making things more complicated than it should be?

Link to comment
Share on other sites

It's turns out that using the render tick events actually works really well for me.  For a workable mod that is supposed to be played by people, not so much.  For my video capture purposes, it works great.  In fact, it's better now.  I can individually build blocks at 120 (or more) individual block placements per second instead of just 20...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.