For this lesson on how to make a multiplayer video game in Unity with the Photon 2 plugin in Unity 3D, I will show you how to create a character selection option that will then synchronize the selected character across the network. Features like the are prevalent in many video games today such as Rainbow Six Siege, Call of Duty Black Ops 4, and Fortnite. This lesson will teach you the basics of RPC or Remote Procedure Call Functions. RPC’s are probably one of the most important principles in developing a multiplayer video game. It is through RPC functions that we are able to sync data from one client to another. After following this tutorial you should be able to create your own RPC function and implement them into your own video games.
In between lesson I create a menu system with four different buttons. This will allow us to selected different characters for us to use as your player avatar prefab. We will begin by creating a new C sharp script called Player Info. This script will save the value of the character our player has chosen.
We then need to create a new C# script that will control do a new menu system. Inside this function, we only need to have a public function that will set the value of the character model we want to use.
We then need to create a Player Info object and a Menu Controller Object. We will then set the on click events of your buttons in our menu system.
We then need to create another C# script. Inside this script, we will create an RPC function that will synchronize our character model value across the network and instantiate it.
If you followed along with the video you should now be able to build your project. Once built you should be able to select different character models which will then be instantiated into the multiplayer scene once connected.