I couldn’t get the “AddExplosionForce()” working correctly over the network. So here is what I did, I’d like to get someone’s opinion if this is the only way to do it…
MY PREVIOUS PROBLEM:
The server always updated the missiles position and also had authority over whether it hit something. So, if a client was to shoot a missile at the server, since the server is doing all the checking and has the most up-to-date position and state of the missile, the player that’s on the server always received the correct “explosion” physics when the “AddExplosionForce()” function was instantiated.
If a server shot the missile at the client however, it would instantiate it like normal on both the client’s and server’s game. If on the server end, the missile collided with the client, the server would send an RPC call to the client basically saying “explode the missile and create an AddExplosionForce() at the missile’s position”. The problem with this was, that by the time the client would of got that message, the missile may of entered within the player’s collider, therefore, instantiating the explosion from inside the player’s collider, making them just go straight up.
MY SOLUTION:
When the missile gets instantiated on both the client and server, each one player sends the missile in the direciton it’s supposed to go, and each player check to see if it hit something. This works great, but I am concerned about lag and the missiles not being in sync… I assume there will be instances where the missile will explode on one players screen, but keep going on the other players screen.
If anyone has any input on whether this is the only way to do it, let me know.