1. Actors and entities

In this part of the tutorial, you start a game and examine some of the SpatialOS entities that correspond to your Unreal Actors.

Watch the video for this part of the tutorial:

In an Unreal game world, Actors are the basic building blocks. The equivalent building blocks in a SpatialOS world are entities. SpatialOS automatically represents all the replicated Actors in your game as SpatialOS entities. Examples of Actors represented as entities include player characters, NPCs and objects in your world like vehicles. SpatialOS does not represent non-replicated Actors (such as UI widgets) as entities, because they are local to each game player.

Entities in the in-game tutorial

In this tutorial, the map Map01_Entities illustrates how SpatialOS creates entities for all Unreal replicated Actors. You move the player character around the map, and see the position of the corresponding entity change.

To open Map01_Entities, follow these steps:

  1. Open the Example Project in the Unreal Editor.
  2. In the Content Browser, open InGameTutorial > Maps > Map01_Entities.

Image: Map01_Entities with two players

1 - Actors and entities
SpatialOS automatically creates entities for all replicated Actors in your game.

In this scene, your player character is an example of an Actor that has a corresponding SpatialOS entity. When you move around the map, you can use the Inspector to see the player character’s entity moving. This happens because the Actor is set to “Replicate Movement”. You can also try this with more than two players.

In Map01_Entities, the Blueprint BP_Map01_PlayerCharacter (InGameTutorial/Blueprints/Characters/BP_Map01_PlayerCharacter) defines the player character. The player character has the Replicates and Replicate Movement properties checked. This ensures that when the player moves, SpatialOS replicates the position of the associated entity to all relevant workers.

Image: Replication settings for the BP_Map01_PlayerCharacter Blueprint

Local deployments with multiple players

When you start a local deployment, your game simulation runs in the Unreal Editor on your development machine. To see multiple entities representing multiple player characters in the game, you can run multiple clients in a local deployment.

To see multiple players in the game at the same time, follow these steps:

  1. In the Unreal toolbar, open the drop-down menu next to Play.
  2. Ensure Number of Players is set to more than one.
  3. Check SpatialOS Networking.
  1. In the Unreal toolbar, click Play.
    The Unreal Editor starts a local deployment.
  2. Play the game. When you are ready to move on with the tutorial, keep your game running.

It may seem that the player should be holding a weapon and that the weapon failed to load, but don’t worry, you will learn how to add weapons later in this tutorial.

Actor data in the Inspector

You can use the Inspector to see how SpatialOS stores Actor and ActorComponent data as SpatialOS entity components. The Inspector’s viewport shows a top-down view of the game map. In the game, when you move your player character Actor around the map, you can see the player character entity moving around in the viewport.

Image: The Inspector window: the icons in the viewport represent the player character entities

To view the player character entities in the Inspector, follow these steps:

  1. Keep your game running in the background and switch to the Unreal Editor.
  2. From the GDK toolbar, click Inspector to open it in your default web browser.
  3. In the top bar of the Inspector, click Comprehensive view > [Default] World view:

If you cannot see the player characters moving around the map, their movement might be too small to be visible at the current viewport zoom level. Click zoom in to see more local detail in the viewport. If you still cannot see the players moving, open the menu next to Save as… and click Reset workspace.

In the next part of the tutorial, you learn how SpatialOS stores data in components.


2020-08-04 Page added with editorial review

Updated 4 months ago



1. Actors and entities


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.