Unity uses PhotonEngine to implement multiplayer online game development (1)

Unity uses PhotonEngine to implement multiplayer online game development (1)

Let’s first learn about PhotonEngine (Photon Engine), which is a network engine developed by the German ExitGame company. Photonengine is simple and easy to use. Many online games developed by game companies use this. This network engine includes PhotonCloud (photon cloud), photonServer (photon server), PhotonQuantum (deterministic quantum engine), PhotonVoice (photon voice). This time we mainly use PhotonCloud, which is simpler than photonServer. The server side needs to be deployed manually, but it focuses more on game design. The management of the server side is completely managed by them. In short, it is complete hosting. But photonServer is more flexible.

Photon Engine provides plug-ins required for various game development platforms. Through plug-ins, the development of multi-player online projects can be realized. Various interfaces are defined in the plug-ins, such as connecting to the server, joining the lobby, creating rooms, etc. Just call it directly and it is super convenient to use.

The following two websites are the global official website of Photon Engine and a Chinese website. You can learn almost all information about PhotonEngine from them. The website includes SDK, teaching videos, various demos, etc.
PhotonEngine's global official website Multiplayer Game Development Made Easy
PhotonEngine's Chinese official website photon engine photonengine Chinese website | Chengdu Dynamic Link Technology Co., Ltd.


Let’s get to the point:
The game engine used this time is unity. Since this development is just for testing, PhotonCloud is used to realize multiplayer online. Of course, if the degree of freedom required for the development of the network part of the project is not very high, You can also use PhotonCLoud, the free one only allows a maximum of 20 simultaneous connections.

Preparatory steps before starting : Register a Photon account on the global official website, then open the second domestic website above, register for the free China Photon Cloud, fill it out, submit it and wait for approval, which usually takes two to three days. Wait until the review is passed and then create the project to get an APP ID. This APP ID is the most important first step for us to realize multi-player connection.
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Among them, Photon Type hangs Photon PUN.
Insert image description here
After the creation is successful, you will see
Insert image description here
that the APP ID is the other step we need to do in addition to registering for free China Photon Cloud.

In short,
the first step: apply for free China Photon Cloud and wait for approval.
The second step: create a Photon Cloud Application and get the APP ID.

After filling in the information, submit it and wait for approval. Even if you have created Photon Cloud Applications and obtained the APP ID before approval, multi-person connection will not be possible. So wait slowly for the review to pass!


To achieve the goal:
  click the link button to test whether the connection is successful, create a room, join the lobby successfully, and join the room successfully, and perform a scene jump after successfully joining the room, and then instantiate the player after the jump.

------------------implementation steps----------------------
  • Open unity and create a new project
    Insert image description here
  • Go to the resource store to download and import the PUN package.
    Insert image description here
    After the import is successful, this interface will appear. Then copy the APP ID you just registered here
    Insert image description here
    and you will be successful. If you don’t plan to fill in the APP ID here, you can also choose to add it in the future. The steps are as follows. Well,
    Insert image description here
    Insert image description here
    so far, these are the preparatory steps for using Photon CLoud to realize multi-player connection. The next article will begin the formal scenario and editing of the test link code.

Guess you like

Origin blog.csdn.net/qq_41294510/article/details/131510888
Recommended