Game States

Game States are ways to organize the different phases of your game. In an FPS, you can have a Lobby state where people pick their weapons. Then the Round begins for 4 minutes and at the end, you enter a Round End state where you can show the score of everyone. After the Round End, the Lobby starts again and the loop is repeated. This behavior is already available in Core without using any script.

Basic Game State Manager

This object is a Basic Game State Manager and allows you to have 3 states by default in your game: Lobby, Round, RoundEnd. To add this mechanic in your game, drag & drop the object into your scene.

This object has different properties, you can define if each state has a duration. If there is no duration, you need to define when the state is finished through a script. For example, the round might have no duration but it can end when one team reaches a score of five points. This will be covered in the scripting part, the last part of the Certification.

In the following image, the lobby lasts 5 seconds, then the round starts for 2 minutes and at the end, you have 5 seconds before entering the Lobby state again.

Basic Game State Manager Properties

Game State Display

There is another object called Game State Display, also available in the Core Content window that shows information about the current state. Drag & drop this object into your scene next to your Basic Game State Manager.

Game State Display Properties

Here is how it looks by default for the player. Feel free to open the Game State Display in the Hierarchy to update the UI.

Try it on Core! Add a Basic Game State Manager and a Game State Display in the scene. The lobby must last 30 seconds and the round 2 minutes.

Add and remove objects for specific states

You might want to add walls for the lobby to keep players inside the spawn or you might want to add extra objects at the beginning of the round, like weapon spawners. The Game State Geometry element is an object that takes an object of the scene (must be networked) as a Geometry property to hide or show this object based on the Properties “ExistsIn” State. In this example, the LobbyWalls is a group containing 4 hologram walls that are around the Lobby Spawn Point. Once the round begins, the collision and visibility of this group are set to false to hide them. When we are back at the lobby state, they are visible again.

The LobbyWalls group is drag and drop from the Hierarchy to the Geometry property
Walls are removed at the end of the Lobby

Try it on Core! Add a group with walls around the blue spawn point that are hidden when the round starts. You must set the material to the Hologram Material and the Camera Collision must be set to Force Off for the group so that the camera is not stuck inside the walls.

Other objects to custom your game states

There are plenty of other objects that can add more variety to your game. For example, Fall Damage, Team Autobalancer, or the Lobby Required Players to start the game if X players are in the game. All those objects can be dragged and dropped into your scene and are totally customizable in their Custom Properties.

Let’s go through each one of these objects as they are the key to create great game loops without any line of code:

  • Fall Damage will add fall damage to all players with a threshold that can kill people.
  • Kill Team Score defines the number of points a team gets when killing an enemy.
  • Lobby Required Players is the number of players required to start the round.
  • Lobby Start Clear Resources is clearing the resources at the beginning of the round. Resources are the subject of a following lesson.
  • Lobby Start Reset KD will reset the number of kills and deaths for each player when going back to the lobby.
  • Lobby Start Reset Team Score will reset the score of each team at the beginning of the lobby.
  • Lobby Start Respawn Players is respawning each player at the beginning of the lobby.
  • Round Kill Limit is a limit of kill that, if reached, will end the round before the end of the timer (if a duration is defined in the Basic Game State Manager).
  • Round Start Skydive is most of the time a Battle Royale mechanic. An airplane is spawned and the player is spawned when pressing space. Then he can press space again to open his parachute. You must drop the Player Settings inside the Custom Property of this object called DefaultPlayerSettings
  • Round Survivor Victory is ending the round when there is only one player left standing. You can also check the ByTeam property to end the round when the other team is defeated.
  • Round Team Score Limit is ending the round when a team is reaching a specific score. The Team Score is increased if the Kill Team Score is in the scene. You can also use the Team Score Display to display the score of a specific team, you will need two instances of this object to show the score of each team.
  • Static Player Equipment will equip an Equipment to a player. Equipments are covered in a following lesson and they can be cosmetics, weapons, abilities and anything that can be attached to a player. You can set a specific equipment for each team by updating the Team property.
  • Team Autobalancer is an autobalancer for your games that has at least two teams. Lots of properties are also available on this project.
Scroll to Top