Multiplayer
To have Multiplayer functionality you need to download Multiplayer for Auto-Battle Framework from the asset store. The installation method is described below.
How to Install Multiplayer for Auto-Battle Framework.
Be sure to install the Auto-Battle Framework following the steps in How to install Auto-Battle Framework?.
1. Download Multiplayer for Auto-Battle Framework from the Asset Store. Import it into a project containing Auto-Battle Framework.
2. Go to Window, Package Manager. Open Packages: Unity Registry, and install the Relay and Lobby packages. They may have been installed when Multiplayer for Auto-Battle Framework was downloaded, and the window that appears in step 3 may have already appeared.
3. Go to Windows, General, Services. In the Inspector click on Dashboard. The Project Settings window will open. Select an organization and click on Create project ID.
4. Click again on Dashboard. You will be redirected to the Unity Gaming Services website.
5. A project linked to Unity Gaming Services will be selected at the top. Select the corresponding project.
6. Once selected, click on Multiplayer, then on Lobby. Click on Set up Lobby.
7. At this point you may be prompted to subscribe to Unity Gaming Services. Please read the terms and conditions of service carefully.
8. You will be shown a series of steps to follow, which correspond to points 1 to 3, so you can proceed directly to the Turn Lobby On point. Activate the option shown on the screen.
9. Click on Multiplayer, then on Relay. Click on Set up Relay.
10. You will be shown a series of steps to follow, which correspond to points 1 to 3, so you can proceed directly to the Turn Relay On point. Activate the option shown on the screen.
Everything should be ready by now. To check it, open the Multiplayer scene, create a new build, make sure the scene is first in the "Scenes in Build" list, and click on Build. Run the scene in the editor and click on the Match button. Wait a few seconds, open the newly created build and click on the same button. You will be able to play the scene in two-player mode. If not, please check the instructions again and repeat the steps.
Scenes description
The following scenes are attached:
Multiplayer: This is an example game where two players can buy units and items, level up their characters and battle against the opponent's team infinitely.
Multiplayer4Players: It is an example game where four players can buy units and items, level up their characters and battle against the opponent's team infinitely.
Connection modes
Three connection modes are included.
Local: In this mode, having two instances of the game open at the same time on the same device, one will be the Host and the other the client.
Relay: In this mode, the player who wants to be the Host must click on the Host button. When doing so, a code will be generated, and it will have to be sent manually to the other player to connect to the same game. This mode is ideal for friends to play against each other. Each player can be on their own device and network.
Matchmaking: Using Relay and Lobby, it allows you to find another player quickly. Each player can be on their own device and network.
Essential operation of the multiplayer.
This section describes three very important components to ensure the operation of the multiplayer mode:
1. GamingServices component: This component allows the use of Relay, Host and Matchmaking. It is very important to correctly enter the maximum number of connections. In two-player mode, a 2 will be entered, in four-player mode a 4, and so on.
2. Network Manager: Responsible for synchronizing all clients with the host, and for having a list of Network Game Objects. Next to it, there should be the Network Object list component, which contains a button to add and synchronize all the characters and actors in the project in the Network Manager list.
3. MP_Connection_State: This is a BattleState that prevents the game from starting unless the minimum number of players have connected. It is very important to enter this number correctly to avoid unwanted game starts. This BattleState must be in the first place of the initial Stage of the game.
How to convert characters and items to multiplayer.
To convert a GameActor to multiplayer, right click on a character or item prefab, and click on "Auto-Battle Framework/Multiplayer/Create NGO Character" or "Auto-Battle Framework/Multiplayer/Create NGO Item".
This will create a copy of the prefab with the NGO_GameCharacter or NGO_GameItem component. It will need to be added to the Shop in the same way as explained in Create a new Game Character (Section 8) or Create a new Game Item (Section 9).
In the case of a character and fusions/leveling up, you will also have to create a Game Character Fusion, in the same way as explained in Level Up a Game Character.
How to create a Multiplayer Battle Stage
This is done in the same way as described in section Create a new Battle Stage, but with a few minor differences:
Instead of using the BattleStates PreparationState and FightState, we will instead use MP_PreparationState and MP_FightState. Both can be created by right clicking on the project, under "Auto-Battle Framework/BattleStates/Multiplayer". The only notable difference is that in MP_FightState it is no longer possible to add BattlePositions, since the positions are given by the players' own characters.
Remember that in the first Stage, the first BattleState must be MP_ConnectionState.
How to create a battlefield for more than 2 players.
You can see how to modify the battlefield for more than 2 players in the section How to create a battlefield for more than 2 players.