Bullet hits on client, not on server - lag compensation issues and best practices

Hey guys, so I have a top down spaceship game that I’m currently working on.

Sometimes my bullets hit on the client, but pass through on the server because of the way I’m doing the instantiation on VERY near misses. (lag dependent)
my current workflow looks like this:

Client presses button, Instantiate is called on client, RPC sent to server to instantiate bullet.
server instantiates bullet.

so of course this occurs because the target keeps moving, and the bullet on the server appears slightly later than the client bullet, and therefore misses on the server, and hits on the client. The game is authoritative, so the client doesn’t take damage or anything. It’s just misleading, as it looks like you hit the target, but they took no damage.

Is there any best practice for dealing with this?
Should i be using network.instantiate on my bullets? as opposed to instantiate?
my guess is no, especially since some of my guns are rapid firing, and managing the networking objects would have significant overhead, I have considered using a bullet pool to pre-instantiate to mitigate this effect.

I could pass where the client fired the bullet from through the RPC, that would enable me to sync the bullets 100% correctly, however the bullets might appear like they were being fired from behind a fast moving target for other peers, as they would extrapolate the position of the ship to compensate for lag, and receive the RPC to fire the bullet with a previous position specified. =/

Any thoughts guys?
I’m sure this is a fairly common problem, and I’d love to hear how you have dealt with it in the past.

Thanks for your input!

I was about to ask exactly the same question. I have problems aswell with bullet’s position sync in my top down spaceshooter game. Im not using network.instantiate to instantiate my bullets either. I pass RPC call to my player character’s networkview to shoot with RPCMode.all. I don’t have networkview on my bullets to minimize bandwidth.

I tried to pass the shooting coordinates to my shooting function but it wasn’t really a success. I am using unity’s physics engine in my game and the problem seems to be in that. The bullets doesn’t behave excatly the same on all clients, which leads to collision fails on player’s character.

I am looking for solution to this problem aswell. It’s the biggest issue in my game at the moment and really need help with it.

This issue is obvious, you instantiate an object which is locally driven on each separate peer using a physics engine and simulation which are not deterministic. That will never work properly.

You can either give one peer full authority over an object and regard that peers decisions as “final” and try to hide any glitches on the non-authoritative peers with effects, etc. or you can change your simulation so it’s always deterministic.

Does this mean that i should not use the ridibodies but transform.Translate instead to simulate the movement of projectiles?

No, not really.

Is it even possible to make non authoritative server deterministic? Where should i start?

Determinism is sort of the polar opposite of authoritative. I think you have the concepts mixed up.