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.
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.
Map01_Entities, follow these steps:
- Open the Example Project in the Unreal Editor.
- In the Content Browser, open InGameTutorial > Maps > Map01_Entities.
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.
Map01_Entities, the Blueprint
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
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:
- In the Unreal toolbar, open the drop-down menu next to Play.
- Ensure Number of Players is set to more than one.
- Check SpatialOS Networking.
- In the Unreal toolbar, click Play.
The Unreal Editor starts a local deployment.
- 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.
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:
- Keep your game running in the background and switch to the Unreal Editor.
- From the GDK toolbar, click Inspector to open it in your default web browser.
- 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