AirConsole Games Features
Connect to your game
Handling players connecting
10min
prerequisites api 1 9 0 or unity plugin 2 5 0 or higher what is player silencing? player silencing allows you to control what happens when a new player joins the game while the game is in an active game round without additional game code it ensures that newly joined players are not known to the game until the game round is finished player silencing is by default not enabled! if you update your game to use the new api it will not impact your game until you decide to enable it comparison with player silencing disabled new players will be added to your game as soon as they connect to the game, invoking onconnect and requiring your game to manually handle and ignore messages as well as visualizing the correct state on the game controller with player silencing enabled new players will be informed that they need to wait for the game round to finish on their controller your screen and controller will only invoke onconnect after the game round is no longer active, which is controlled by your screen calling setactiveplayers(0) how does player silencing work? player silencing works by keeping track of new devices connecting while the game is in an active game round the onconnect event of such devices will be delayed until the game round is no longer active once the active game round is no longer active, all waiting onconnect events will be executed, unless the device has disconnected already who is player silencing for? player silencing allows you to be sure that after a game round is started, newly joining players are requested to wait until the game round is finished this does not require additional game code to prevent an impact to the game experience or the game rounds outcome when not to use player silencing? if your game is designed to allow players to join at any time, then player silencing is not for you how to guides how to enable player silencing to enable and use player silencing, all you need to do is to configure airconsole to use it on the screen web setup include silence inactive players true silence inactive players true when calling the constructor var airconsole = new airconsole({ silence inactive players true }); unity setup enable the checkbox silence players silence players on the airconsole component in the scene how to use player silencing after enabling playing silence, you can control when new players can join using setactiveplayers once player silencing is enabled, during any phase of your game where you setactiveplayers to anything but 0, new joining players will be silenced after setactiveplayers(0) is called, the game will be in a waiting state and new players will be added to the game players that are already waiting to join will now be added and onconnect is called for them the example pong game explained we will use the pong example game , to explain player silencing and how it applies we initialize airconsole including the silence inactive players true silence inactive players true flag when creating the airconsole object, signaling that new players to automatically wait during active gameplay the game is initially in the lobby state, waiting for players once 2 devices are connected and the master device starts the game, the game switches to the game state entering the game state executes setactiveplayers(2) setactiveplayers(2) , starting the active pong gameplay if any additional device connects while in the game state, the new device will be silenced and the controller will inform the user with the following screen after the game ends, the screen enters the lobby state, which calls setactiveplayers(0) setactiveplayers(0) to mark no controller as active player after setactiveplayers(0) all players that joined while the game was ongoing will now join the game, showing the currently active controller we provide a full example implementation as a 2 player pong game with dedicated game states game states lobby new players automatically join the pre game waiting state until the main controller decides its time to start in this state, setactiveplayers(0) was called game in this state, new players need to wait to join (they are silenced ) in this state, setactiveplayers(2) was called you can find this example pong game at https //github com/airconsole/games pong