Download

How to replicate weapons in multiplayer FPS /3rd ?

Hi,

I would like to know how you guys are replicating weapons in a multiplayer FPS / 3rd game?

I need characters able to pick up weapons - like in CSGO (example) - replicating the weapon currently equipped to all clients (in order for other players to see it).

What would be the best / most optimized way of doing this ?

Currently I attach the weapon (blueprint actor) to a socket on the character mesh - the weapon is spawned then attached - but when the character moves the weapon does not move with it, instead it hovers in the air at the location where it was attached… how is blueprint actor movement over the network replicated?

Any ideas?

Thanks,
JP

  1. “Replication” means “This is something the server should share with the client”, not the other way around or client to client.
  2. When spawning an actor, spawn it on the server only and make sure that “Replicates” is checked in the default panel. If the server spawns a replicated actor, all the clients will see it too.

I guess that’s it. So you’d want to have

<Trigger>
<Call Custom Function: SpawnEquipWeapon>

<SpawnEquipWeapon (Custom Function, run on server)>
<Spawn Actor From Class>
<Attach Actor to Actor>

So pretty much the only thing the client does is start the event with the trigger (probably have it be a collision detection) then tell the server it wants to spawn a weapon. The server spawns it and attaches it, all of which is replicated… actually you may need to have “Replicate Movement” checked on the weapon blueprint as well, I don’t know if “Attach Actor to Actor” qualifies as movement or not.