Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How come ghost prediction runs multiple times a frame?

Discussion in 'NetCode for ECS' started by l33t_P4j33t, May 3, 2022.

  1. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    Simple question: why does ghost prediction run multiple times a frame?

    in the past with the gameobject workflow with the youtube tutorials i was following, prediction would run just once then sleep until the next fixed timestep just like on the server.
    then only in the case where there was a significant disagreement with the server, you'd redo all the prediction frames with the new correct data you've just received.

    but here ghost prediction runs 3-4 times EVERY normal frame.
    what is it doing in those frames?
    is this because of my bad implementation that's causing constant disagreement with the server, thus triggering ghost prediction to re predict frames?
     
  2. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    oh so judging by this post, it always redoes prediction with latest server frame irrespective of anything?
    https://forum.unity.com/threads/interaction-between-predicted-ghosts.1095562/
    that's pretty smart, so the game can run at any fps and not having things like position update at fixed fps like what you see with csgo.
    what's the ideal way to handle stuff like sound for example when you fire?
    it would obviously play the sound multiple times in quick succession. the only solution i got to work was to just have a cooldown timer, but it seems like a hack solution. if you do it only in isFinalTick, it doesn't play the footstep sound sometimes
     
    Last edited: May 3, 2022