Hey everyone!
In this update, I’m excited to share how we tackled Role Selection in our Unity 3D multiplayer heist game using Photon PUN2. One of our key goals is to ensure that each player has a unique and meaningful role in the heist — and that the selection process is smooth, networked, and fully synchronized.
---
Players can choose from the following roles:
Group Leader – Coordinates the team.
Hacker – Guides the team inside the bank .
Lock Picker – Opens restricted areas.
Insider – Has access to server room and is responsible for stealing digital money.
We used a single dropdown menu per player to allow role selection. Once a role is picked by a player and they hit the "Select Role" button, that role is instantly removed from all other players' dropdowns in real-time using Photon RPCs. No duplicates allowed — just like in any real heist, you need a specialized crew!
---
Each player’s dropdown is synced across the network.
When a player selects a role and confirms it:
The selected role is broadcast via a Photon RPC to all clients.
The role is removed from everyone’s dropdown menu.
The selection UI gets disabled for the player who locked in their role.
We track selected roles on the server using a shared list in the Photon Room Custom Properties.
---
To keep things coordinated:
A "Ready" button is assigned below the dropdown role selection.
The game only starts when all 4 players have selected their roles and pressed Ready.
Once all 4 have selected their roles and pressed the Ready Button the game proceeds to the main scene the "Bank" scene .
Only then can the game transition to the heist scene.
---
No confusion — players know exactly which roles are available.
Clean and efficient UI — no clutter, no duplicate dropdowns.
Fully synchronized — thanks to Photon, no desync issues or accidental double-picks.
Encourages teamwork — forces communication and planning before the heist begins.
---
The syncing seemed to be an issue as for some reason one of the role when selected took 2 roles instead of one leaving the last player with no role and just had to press the Ready , and a ArrayOutOfBoundsException Error
How I Fixed it ? The issue arised from the "Ready" button which seemed to be using 2 function "ClickReadyButton" and "SelectRole" Button even though i added both the functions to the Ready Button they simply did not work they way i expected so I made another button for SelectRole function , for the ArrayOutOfBoundsException Error i used Photon's unique player ID instead of number of players, as it is a dropdown menu i worked with List and Dictionary to create a List of roles from the dropdown value.text and make a list of roles which were already selected and then they were removed. After that it updated the List with the remaining options which remain unselected
I contacted my professor regarding my game and he informed that since my game was running on a local Server ie MAMP it will not get good marks as the player also needs to have MAMP running which is not reasonable a Player who has the Build but not The MAMP cannot go past the Login/Register Phase, since this is a group project I decided to handle the AI mechanics of the game that is the tasks that all the 4 crew member will do while my friend handles the Networking while setting up both MySQL on some free server available which does NOT require player to download MAMP separately. So from now on i will be making game updates in offline mode while my friend adds a few lines of Photon Pun code to convert it into a multiplayer game. I share my project and updates with my friend using GitHub.
This system was both a UI/UX challenge and a networking puzzle, but seeing it all come together was super satisfying. Up next, we’re working on stealth mechanics, patrol AI, and maybe even custom role abilities in the gameplay phase!
If you’re into multiplayer design, or building your own networked games in Unity, I’d love to hear your thoughts or questions!
Stay tuned for more behind-the-scenes dev logs.
– Viplav Patel
Game Programmer & Designer
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.