Spawnig a networked projectile in a clean way

So I am trying to find a clean way to spawn a networked projectile.

So I am spawning 2 projectiles 1 on the local clients system and the 2nd on the server that is being replicated to all client including the local client but is indivisible for the local client. The movement of the projectile is not replicated but tone individually.

I actually didn’t want to use an intermediate class to link the server and client version of projectiles.
Like e.g. The server version of the projectile that is being replicated to the local client need to interact with the local version of the projectile that is spawned for the client only.

The only why I can think of is in the class that is spawning the projectile, detect when the Server projectile is being replicated on the local client through an OnRep and then pass to pointer of the projectile spawned on the local client to it.

This is working fine but is there a better way to do it. Another idea is to use a projectile spawning class handling the spawning of projectiles.

Spawning a ‘fake’ projectile that doesn’t interact with anything and merely shows a visual representation is fine, this is what Unreal Tournament does.

UT replicates the movement from the Server for the ‘Real’ projectile, and the Client lines up their ‘fake’ projectile to that one when it recieves it. The key thing is to make sure that your client projectile really is only a visual representation and doesn’t affect gameplay at all. You also need to handle cases where a projectile from the server arrives after the client one has already expired for example, which can happen if it only exists for a short period of time.

If you’re spawning lots of them at once, pooling them might also be a good approach, and reusing them when neccesary.

Well I want the server version of the projectile to detect the client version because the projectile might have systems in which they might get attached to the target or destroyed.

So basically I want to give that information to the client.