Skip to main content

Asynchronous multiplayer: Preparing the scene

info

For the tutorial purposes we are creating an extremely simple project that will consist of one synchronized object, 4 scripts and a set of UI elements to display the game logic. Once you’re ready to create a more complicated game we invite you to read about Elympics SDK capabilities in our documentation at docs.elympics.cc.

Creating elympics objects

For Elympics to work in your game, the gameplay scene needs to contain the ElympicsSystem object. To add it, right click in the hierarchy window and select Elympics > ElympicsSystem.

CTZ

Elympics can support any number of synchronized entities, but keep in mind that each synchronized value adds to the amount of data that is being sent and received by the game. In the case of bigger projects it’s important to be smart about choosing these values and focus on synchronizing only the important ones that influence the game logic the most. For an object to be considered a part of synchronized logic it must contain an ElympicsBehaviour component. Let’s create an empty Game Manager object and add ElympicsBehaviour to it. In the Predictable for section we need to set the prediction to Player, for the object to be updated by both the server and the player instance of the game. If the prediction was set to None, only the server would update the object and players would receive information about it with a delay.

CTZ

The four scripts that we will create for our game will be:

  • GameManager - which will update the main game logic
  • MapManager - which will hold synchronized information about the map containing obstacles
  • PlayerManager - which will manage player’s input and hold information about player
  • DisplayManager - which will update our UI and display games logic

Once created add them all to the manager object.

Preparing the scene UI

The elements of UI that we’ll need to include are the following:

  • Score - text object to display players score
  • Timer - a slider that will be showing how much time we’ve got left in the game
  • 5 rows of tiles - a 2 column grid of images what we will use to show which tiles are safe and which have obstacles on them
  • Player - an image that we will move around to show whether the player is on left or right
  • Buttons - 2 invisible buttons spanning the whole screen that we will use to detect players input
  • GameOver screen - an object containing an image and 2 text objects that we will activate when the game will have ended

CTZ

CTZ

With everything set up, we can start programming in the game logic.