Search Unity

Syncing dilemma - Design question

Discussion in 'NetCode for ECS' started by Enzi, Feb 25, 2021.

  1. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Hello all!

    Nice being able to post in a sub-forum! :) Thanks!

    I have a syncing dilemma and I'm interested in ways this can be solved.
    First the pre-requisites of what is happening. The value in question is for an energy bar that is used to cast skills and gets stored in a dynamicbuffer.

    It starts at 100, the skill is cast with 33 energy costs and it's 67 for 1 frame. Then the energy value gets overwritten with values from the server and after some time reaches the correct value of 67 again.

    Format is: Tick Entity EnergyValue LastResourceTick
    upload_2021-2-25_5-13-14.png

    Obvious first solution would be to handle the prediction correctly. Casting the skill and reducing the energy costs only runs once. Prediction has a great cost though so I'm searching mostly for solutions without the need to predict.

    Second solution I can think of would be to introduce a local unsynced lastTick and a synced lastTick in the buffer and check against those.
    I'm using it in some other places already. Which is exactly the reason why I dislike the solution. It should be handled more globally (not necessarily by NetCode), I think, so it would not overwrite the data in the first place, feeding the systems with old/wrong values.

    Maybe some of you have already tackled this issue on several angles. I'm interested in your solutions.

    Thanks
     
  2. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Just to give an update to this. I've rewritten the system so the prediction will always run. It's too much of a hassle otherwise. The buffer sync system that I've written before it was supported in NetCode wasn't tick based so it really got in the way. As DynamicBuffers can also be synced now this works really well.