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)
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: