Replicating Character Weapon

I am working on a multiplayer first person shooter. Each character has a field: * TArray<AWeapon*> weapons * as well as * AWeapon * currentWeapon *.

When the character switches weapons, I simply hide the one from view mesh->SetVisibility(false) and make the other visible. All of my weapons have bReplicates set to true so surely this should work
on a network?

On character BeginPlay(), I hide all weapons except for the currentWeapon. Currently, all weapons are showing. What am I missing? (I think I underestimate the power of bReplicates = true)

Are you using
AWeapon* currentWeapon

I’m not sure but maybe:
might be something to look at.
In connection with that:
DOREPLIFETIME(AActor, MemberToReplicate).

Replication doesn’t work like that, It’s not that easy. bReplicates simply tells the game that at some point, you want to replicate properties from Server to Client. It doesn’t necessarily know what or more importantly, how to do it. You need to write discrete code that tells the clients to only show one weapon for example. Just making it a replicated value does nothing.

I suggest looking at ShooterGame code to get an idea of how this works, and also doing some further reading here:

A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums,Using_ReplicatedUsing/_RepNotify_vars

Multiplayer / Networking is a complex beast. It’s worth experimenting to get the gist of how it works before attempting something too complex.

Thanks alot Jamsh, I’ll have a better look into it.