AirConsole Games Features
Main Screen & Controller
Multi-screen multiplayer
13min
prerequisites api 1 9 0 or unity plugin 2 5 0 or higher key concepts explained an environment, as provided by airconsole for the screen device, is a limited environment that the current screen is part of a multi screen multiplayer session is an online multiplayer session where airconsole screens act as players in an online multiplayer game the primary screen is the screen responsible for all decisions in an ongoing multi screen multiplayer session secondary screens are additional screens in a multi screen multiplayer session that have no responsibility and ability to make decisions the primary controller is what you receive from the api using getmastercontrollerdeviceid() the primary multi screen controller is the master controller of the primary screen an environment defines a grouping of multiple screens that share one or more characteristics an identifier in an environment enables the screen to identify the current (physical) environment they are in, like a specific car a partner in an environment enables screens to identify other screens in a similar environment, for example the same brand of car multi screen multiplayer what is it and how does it help us to make more engaging games? what is a multi screen multiplayer game? a multi screen multiplayer game in airconsole is an online multiplayer game that uses additional information to enable matchmaking to allow screens in a single physical environment (a single car with multiple screens for example) to play together enable matchmaking to allow screens on the same general environment (cars of a brand, web) to play together with a similar experience across multiple physical environments these new capabilities make it possible to create multiplayer games suitable for in car entertainment that provide a comparable, fair experience to the different players how can my players play together on multiple screens in the same environment / car? to enable games to implement environment based multi screen multiplayer gaming, airconsole provides the screen device with information on the environment it is part of this environment contains the so called environment identifier ( id ) that identifies the environment the screen is as uniquely as possible an example of such an environment can be a single car with one or more screens, which all share the same id to ensure reliability of multi screen multiplayer game implementations created today, airconsole always provides an environment with a valid id and partner for screens that are not part of a specific physical environment, an environment with a generic id and partner is provided players in this case would play against other screens purely online without being in physical proximity to each other how can the environment identifier be used to enable multiple screens in the same environment to play together? after the environment with its id is obtained on the web or in unity, the game can use this information to identify waiting games from other screens in the same physical environment example usages of the id would be in a solution like photon fusion , the environment id can be used as the sessionname in the startgameargs to either start or join the same game session of this particular car in a solution like photon realtime , the environment id can be used as the room name to either create or join the same room of this particular car this way, the game can ensure that only players in the same physical environment can play together, while those without a specific physical environment can play it is in this context simplest to think of a screen as a group of players that in the multiplayer context act like a single player one of the screens, we call it primary screen , would be the primary screen that would be responsible to handle the configuration of the multi screen multiplayer session the primary multi screen controller of this primary screen is in that sense the primary controller for the whole session, while the main controller of the secondary screen must not have any special rights how can the partner be used to improve multiplayer games? after the environment with its partner is obtained on the web or in unity, the game can use this information as a grouping parameter to provide match making between devices of the same platform or car brand in a solution like photon fusion , the partner can be used in sessionproperty in the matchmaking api through startgameargs to either start or join games running on the same partner platform in a solution like photon realtime , the partner can be used in opjoinrandomroomparams to enable random match making to only take place against other screens on the same partner platform best practices best practice for multiplayer on multiple screens in the same environment / same car query the multiplayer platform to see if a room / session with the same environment id already exists when the query result is received if a corresponding room / session exists, the screen should offer the option to join the other screen if no corresponding room / session exists, the screen should offer the option to start a multiplayer game in the car in this case the screen starting the multiplayer would need to wait for the second screen to join and confirm their readiness before the multiplayer round starts best practice for using the environment identifier and partner in multiplayer games unless there is a strong reason against it, always use the environment partner as a grouping parameter in room / session creation as a filter in match making together these will ensure that players on the same platform or car brand with similar performance metrics play together when multi screen multiplayer in a single physical enviroment is supported use the environment id as room / session name use the environment id to query for pending games in the same physical environment and join them best practice for handling screens and master controllers only a single controller must be considered the primary multi screen controller of all screens after multiple screens are in the same session only the primary screen must be able to configure and control the multi screen multiplayer session when the primary screen leaves the multi screen multiplayer session one of the secondary screens needs to be promoted to become the primary screen only the new new primary screen must have the ability to end the multi screen multiplayer session to continue on a single screen in consequence the master controller of the new primary screen also becomes the new primary multi screen controller how to access the environment information on the web var partner = undefined; var environmentid = undefined; if (airconsole devices\[airconsole screen] hasownproperty("environment") { var environment = airconsole devices\[airconsole screen] environment; environmentid = environment id; partner = environment partner; } var environmentid = undefined; var partner = undefined; var airconsole = new airconsole({}); // somewhen later for example as you reach the multiplayer matchmaking part of your game if (airconsole devices\[airconsole screen] && airconsole devices\[airconsole screen] hasownproperty("environment")) { var environment = airconsole devices\[airconsole screen] environment; environmentid = environment id; partner = environment partner; } you also get this through the ondevicestatechange event, checking for the sending device id === airconsole screen and then accessing device state environment id be aware that the initial device state update might not yet contain the information, so always check if device state hasownproperty("environment") var airconsole = new airconsole({}); airconsole ondevicestatechange = handleondevicestatechanged; function handleondevicestatechanged(device id, device state) { if (device id === airconsole screen && device state hasownproperty("environment")) { const { environmentid, partner } = device state environment; // do something with the partner and environmentid or do something with device state environment itself } } in unity jtoken devicedata = airconsole instance devices\[airconsole screen]; jtoken environment = devicedata?\["environment"]; string partner = environment?\["partner"]? tostring(); string environmentid = environment?\["id"]? tostring(); you can also get it from the ondevicestatechange event airconsole instance ondevicestatechange += handleondevicestatechange; void handleondevicestatechange(int device id, jtoken device data) { jtoken environment = device data?\["environment"]; string partner = environment?\["partner"]? tostring(); string environmentid = environment?\["id"]? tostring(); // do something with the partner and environmentid or do something with environment itself }