Exploring 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 it won’t be able to do replication operations such as variable replication (covered in the Understanding variable replication section) or call RPCs (covered in Chapter 17, Using 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 calling RPCs) on an actor, the network framework will get the actor’s connection by calling the GetNetConnection()
function on it. If the connection...