Strix Lifecycle in a Game

This section summarizes what and when you should do to use Strix in your game.

Initialization

The first step you need to do in your Strix-enabled game is to initialize the Strix network. This is done by calling InitializeStrixNetwork function from Blueprint. (See Connection for more details.)

You can do so at any time in your game, but before using any other Strix functions or spawning any Actor that has a Strix component attached to. Most games call the function in GameInstance class, in GameMode class, or in the initial level Blueprint on the BeginPlay event.

Connection to servers and matchmaking

The basic server-side system of Strix consists of a single master server and one or more room servers (though a single server instance can work both as a master server and a room server in a small scale game), and a room server can contain multiple rooms. (See Strix Architecture Overview for details.)

The logic and criteria to choose one particular room among (possibly) many available rooms (i.e., matchmaking) depend on your game design, but anyway you need to join a room to share a game world (i.e., replicate and synchronize Actors) across clients. To do so, you need to connect to the master server, then connect to an appropriate room server (among possibly multiple of them).

A connection can be achieved in several ways, and it is up to you to decide which best fits your own game. The most typical setup will involve the following steps on the game client, in this order:

  1. Connect to the master server.

  2. Issue queries to find a list of possible rooms.

  3. Pick a room in the list (or create one if none fits) to join.

  4. Connect to the room server that hosts the room and join it.

(See Master Server Connection, Room Server Connection, and Rooms and Matchmaking for more details.)

Replication and synchronization

Once you join a room, Strix components replicate and synchronize Actors to/from other clients in the same room, so that those players share the same gameplay.

To do so, you need to attach an appropriate set of components to each of Actors in your game. (See Gameplay Synchronization for details.) If you want to perform something more than Strix components can offer, you can also use Remote Procedure Calls to make more control over Actors.

Destruction of replicated objects

An Actor that becomes unused is destroyed. When an Actor with Strix Replicator component is destroyed, what happens depends on whether the Actor is the original spawned locally or a replica from another client. When the original Actor is destroyed, all of its replica will be deleted from all clients. When a replica is destroyed, however, other replicas or original on other clients are left as they are. That means your game logic should only try to destroy the original Actor, and let it delete all its replicas. (See Ownership to know how to do it.)

Sometimes, you may want to protect your replica from Unreal Engine’s automatic deletion of Actors, e.g., by switching to a new level. You can temporarily pause Strix’s destruction-propagation if needed. (See Pausing.)

Termination

When you have done with a room (e.g., for winning a match, being eliminated, or whatever) you leave a room or disconnect from the room server. A room that becomes unused will be deleted. (See Leaving and Deleting a Room for more details.)

When you have done with the online features of your game (and probably you get back to the standalone offline gameplay, or you are quitting the game client itself), you can stop Strix network. (See Stopping Strix Network for details.)