Introducing the actor system
We learned what game object extensions were, and how to use them, in Chapter 3, Creating and Utilizing Custom Entities. We'll be building upon this knowledge to create a custom actor in C++ and C#.
Actors are represented by the IActor
struct, and they are the game object extensions in the core. This means that each actor has a backing entity, and a game object to handle networking and the IActor
extension.
Actors are handled by the IActorSystem
interface, which manages the creation, removal, and registration of each actor.
Channel identifiers
In networked contexts, each player is assigned a channel ID and an index for the Net Nub, which we'll cover further in Chapter 8, Multiplayer and Networking.
Actor spawning
Player actors should be spawned when a client connects to the game, inside IGameRules::OnClientConnect
. To spawn an actor, use IActorSystem::CreateActor
as shown:
IActorSystem *pAS = gEnv->pGameFramework->GetIActorSystem(); pAS ->CreateActor(channelId...