Connections and Ownership
When using multiplayer in Unreal Engine, an important concept to understand is that of a connection. When a client joins a server, it will get a new Player Controller with a connection associated with it.
If an actor doesn't have a valid connection with the server, then the actor won't be able to do replication operations such as variable replication (covered later in this chapter) or call RPCs (covered in Chapter 17, Remote Procedure Calls).
If the Player Controller is the only actor that holds a connection, then does that mean that it's the only place you can do replication operations? No, and that's where the GetNetConnection
function, defined in AActor
, comes into play.
When doing replication operations (such as variable replication or call RPCs) on an actor, the Unreal framework will get the actor's connection by calling the GetNetConnection()
function on it. If the connection is valid, then the replication operation...