Networking: When To Use What (also how to make a FPS inventory for multiplayer)

SlayerOfPrimis
Wed, 14 Jun 2023 03:44:07 +0000
Multiplayer & Networking

I’m a C++ programmer trying to get a full grasp on Networking in Unreal Engine.

What I Know
I’ve completed the official Multiplayer Quick Start from the documentation.
I understand the concepts and rules of Actor Replication.
I understand how to replicate a variable, and how to set up a RepNotify.
I understand how to set up an RPC, as well as the different types.
I understand the general concepts of Relevance and Priority.

What I’m Asking
What I’m still lost on is how I should put those things together into a working game.
As in, what variables of an Actor should replicate? What should the flow of RPCs and non-RPCs be?
As an example, I’m not necessarily looking for an answer to “How do RPCs work?”, but rather “Why/When should I use an RPC?” and “When should variables be set to replicate?”.

What I’m Working On
I’m putting details about my current project/problem here, in case it’s useful.

In my current project, I’m trying to get a FPS weapon system multiplayer-compatible.

I have a ShooterCharacter that has an WeaponInventoryComponent attached. I have a WeaponActor class. All of these classes have replication enabled. The WeaponInventoryComponent handles what WeaponActors the character has, and which one is currently equipped. Information on how to make this setup network-compatible would also be appreciated.

Currently, when I run as a Listen Server, a “server” player can obtain and equip weapons as intended. However, “client” players are unable to equip weapons. Client players fail to equip them because their Casts to EnhancedInputComponent and EnhancedInputLocalPlayerSubsystem fail. Currently, these casts happen in a Client RPC in the WeaponActor class.

10 posts - 3 participants