Especially when spawning. It is a chaotic moment where everything is out of sync. And whatever you do, you are never in the right place or at the right time. And it is a headache to know who exists first and who exists after. Because sometimes it’s one and sometimes it’s another.
So I think a delegate is not the best solution in this context.
You can put a timer and check the variable every so often. But if you do this for each variable your program will have hundreds of timers.
You can also store the new value of the variable in an array and simulate an event queue. But what if client and server read and write the array at the same time?
So… What is the correct way to handle this situation?
Thank you so much!!
firstly you can post raw code by on a new line hitting the lower-case Tilde “`” x3 then on another line do that again
anything in the lines between those will be a code block
I will presume you are aiming for something like a lock-step, or maybe a roll-back. if you are going to be spawning things often, and maybe destroying them,
one option could be a sudo-pooling especially where you can only spawn 1 thing, or 1 of a thing at a time. you just spawn 1 ahead of time, and then when you actually need them you enable it (turn on the bIsVisible, change the Physics to enabled, and activate Ticks/Timers), then set up to spawn another.
the above could be really leveraged if you have a modular Actor/Pawn/Character where if they share functionality, but the only real difference is the model and attachment things you Spawn the Default, and then put the modified pieces on when the “spawn” happens.
the option that might require the “least” modification of the underlying implementation you have is to add a float Time to your broadcasts where it sends along timeSinceStart or some other meaningful Time, and you use that as the decider in the networking Race Condition.
please understand that a Network broadcast utilizing Time will be very connection sensitive, and have a little tolerance for"Floating Point Approximation" as that can easily happen, and be frustrating for a playing will the slower connection.