edogdu / RAM_Cyber_Defenders

Cybersecurity Learning Game in AR/VR Environment
2 stars 1 forks source link

Multiplayer Mode (Connect to the server, type the nickname, join the room) #67

Open landerson25 opened 1 month ago

Luk-Er4 commented 1 month ago

I could refer to this YouTube video. It explains how we can make the game in multiplayer mode.

Also, it shows the free server we can use, called "Photon".

-Video-

https://www.youtube.com/watch?v=93SkbMpWCGo

-Photon Page-

image

The video provides detailed instructions.

  1. Create the Photon account and get an App ID. (Only one person needs to do this!)
  2. Go to the Unity asset store, download PUN 2, and import it to the Unity project.
  3. After importing it, put the email address and App ID when we do verification and connect to our server.
  4. Write a code with functions with special methods in Photon API. (We can create a room, and join the room based on the room ID.)
  5. Now we need to find the way to make the players move in realtime.
Luk-Er4 commented 4 weeks ago

We can choose to make "Quick Play" or "Private Game" or both.

In the Youtube video above, it explains how to create "Private Game" mode, and the thing is how to implement the keyboard.

The point of the "Quick Play" is how to make Queue system in the game.

It would be a lot easier to make "Private Game" mode if we know how to implement VR keyboard.

I am working on "Private Game" mode for now. No plan for "Quick Play" mode yet.

image

Luk-Er4 commented 4 weeks ago

This is the video of the process; type nickname, connect to the Photon server, choose to create or join the room by entering the code, and arrive Multiplayer scene.

https://github.com/user-attachments/assets/998359ff-f64f-4c2e-9d31-0d99dc88c2bd

Three extra scenes were needed to conduct this task, and I could pass the nickname string data to the other scene so that we can keep the nickname.

The picture below shows the graph of CCU, which represents the number of the current players connected to the server.

The time is shown in the GMT timeline, so it proves that I was using the server alone.

image

Luk-Er4 commented 2 weeks ago

=For anyone who will work on this project=

Multiplayer mode requires you to use Photon API or Netcode API in Unity.

There are some points about multiplayer mode:

  1. What to sync and how to sync the objects in the game scene connected to the server
    • How to sync the nickname to the game scene
    • What do you want to sync and what do you not want to sync? (card movement, hand prefabs...)
  2. Distinguish the player's object and others object
    • Look up "IsMine" in Photon, "IsOwner" in Netcode

+. If you want to make it detailed, you need to look up network variables.

I could let two players in the same room, but I had trouble with syncing the other game objects.