Round System


IN-DEPTH LOOK: the round management system

Hello people, gab here! Today I’m going to explain in more detail how the game handles rounds and some other inner workings of the game system. This system was quite difficult to implement at first since I had to change a number of other systems that I implemented in the first iteration of the game.

the system is composed of 4 main parts:

  • Player manager object
  • Map spawner object
  • Player spawn manager
  • Cameras

I will now start to describe in detail these parts and how they interact with the “Player” object

-------PLAYER MANAGER-------

Truly the most complex of the four parts and the one that is being constantly updated and fixed in some way. This is the brain of the round system, counting the rounds, keeping track of who is winning, sending messages to the ui and the players themselves and overall dealing with the multiplayer aspect of the game.

The player manager is composed of the player input manager that is provided by unity and three custom scripts: RoundManager, Preround and Uimanager.

  • Roundmanager: this code is the one that deals with the round per round system and communicates directly with the players. As the game starts it checks if any controller is connected and as soon as it receives an input from one and the player input manager creates a new player, it adds the player to the list of active players and sets their action map to the car selection actionmap. Whoever is player 1 is also tasked with starting the game, this can only happen if all the players have selected a car, this will make the round manager start the game, telling the map spawner to create a map and the player spawn manager to teleport the players to their specific locations. During the game if a player dies, a message is sent to the roundmanager which in turns updates the “playeralive” counter and checks if it has reached 1 (which means that there is a winner and the round is over), here the manager updates the score of the survivor, checks who has the highest score and creates an effect above them and finally resets the health of the players while spawning a new map. Whenever a player reaches 5 wins, the game is considered over, all players gets teleported to the winning screen and after a small cooldown the game resets.
  • Preround: this is a rather simple code that helps the car selection process by communicating with the players when changing cars and giving visual contexts like a slow rotation while the cars are “unselected” and stopping the rotation when they are.
  • UImanager: The script UImanager is the one that instantiates the UI for the game when it starts, it also holds the entire list of icons for the powerups that the players will be able to get during the game. When a player dies, they randomly get a powerup from the list, they then send a message to the UImanager script telling them the number of the powerup and which player they are, the script then checks the list for the right game object (each icon is a different game object for ease of use) and adds it to the respective player spot in the ui. Since the ui uses a grid element it’s easy to add and remove the icons without many alterations.

Due to the fact that the player manager has mostly public variables and functions, there is a number of other game objects that “checks” specific variables like the score, the number of rounds etc. For example one of these is the random material script in each object of map, which changes some values depending on how many rounds have passed since the beginning of the game.

--------MAP SPAWNER--------

The map spawner is the object in charge of spawning maps between rounds, it is quite a simple script that has some interesting functions behind it. On the first round, a random map is selected as the “current” map and another one will be selected as the “next”, on the next rounds the map that was considered “current” will then become the “last” , the “next” then becomes the “current” and a new “next” map is chosen randomly but excluding both the “last” and the new “current”. Although this seems intricated for no reason it’s actually useful for not having too many repeats of the same map over and over. 

The map spawner also has a usefull feature where you can decide which map is going to spawn for testing purposes.

-------PLAYER SPAWN MANAGER------

The player spawn manager is the most simple out of all of the round system objects, it’s simply a game object that holds four other object which are the “spawnpoints” for the players, whenever a player needs to spawn in (usually at the start of a round) it checks the position of the spawnpoint of the same value as them (player 1, spawnpoint 1) and teleports there. A small interesting thing about the player spawn manager is a small script called Findfloor: Findlfoor is used each time a new map is spawned in and it teleports the player spawn manager up by 10 units, create a raycast downwards to find the position of the new floor and then teleports downwards to the new height. The reason I’ve decided to create findfloor is to fix a small problem where the player would start the round high in the air every time which would make the start of the round hectic with the cars not being equipped to handle verticality.

-------CAMERAS-------

Since in the project we use cinemachine, cameras are incredibly easy to set up. This helped us a lot in terms of time and coding issues that could have been raised if we used the basic cameras provided by unity. There are four main cameras that are used in the game:

  • Selection screen camera: this camera is the one that shows the car selection screen, it utilizes a volume profile that blurs the background while ignoring the ui elements and the pedestals where the cars sit
  • Game camera: this is the camera used during the rounds, it’s a top down view of the arena where the players spawn in and has a volume profile that adds bloom to the scene which creates a nice visual effect for explosions and other particle effects.

  • Player Camera: whenever a player wins a round, this camera will start to closely looking and following them for a few seconds before returning to the Game Camera
  • Win Camera: at the end of the game, this camera will look at what’s called the “win zone” where all of the players are teleported and the ui shows whoever won.

Get E-Racer

Leave a comment

Log in with itch.io to leave a comment.