Download

Networking: Spawing projectiles for all clients and server + registering hits.

So I’ve set up aiming so that its visible for both client and server and now have firing functionality however, the spawning of the emitter for the muzzle, projectile and effects for the projectile hitting is only shown for the player firing it. Does anyone have a good visual example of firing a weapon where all effects are visible to all players?

Also to that note, how would hits be registered?

There are lots of ways to handle projectiles & hits & visuals in multiplayer games.

I know a bit of the logic regarding “the best way to do it if you have lots of bullets” but I’m far from being able to tell you how to build it.

However I can tell you how you can prototype it and get it to work if you don’t have too many bullets spawning (how many characters, how many firing, how many bullet spawns in a second).

The logic would be: the projectile is a replicated actor which doesn’t have replicated movement.
The projectile actor has a projectile component that will make it move without any replication involved on any machine.
When someone fires, the server creates a projectile at the desired location.
On event begin play of the projectile you play every visuals you need (without authority).
Since the actor is replicated, it will spawn on every remote machine, its begin play code will be executed everywhere.
Regarding the damage, on event hit (or overlap) of that projectile actor, play visuals effects you need (without authority) and then deal damage to the actor hit if you have the authority.
This way, damage will be handled by the server and visuals will be seen everywhere without replicating anything but the initial projectile actor.

The client projectile are basically only visual stuff when the server projectile is the “real” one that actually deals damage.