Back To Home
Photon
5-04-2024
Welcome to our Photon Unity tutorial series! In this series, we'll explore game development using Photon Unity Networking (PUN). This series is here to guide you through the process in a clear and easy-to-follow manner.
Throughout this series, we'll cover everything you need to know to get started with Photon Unity Networking. We'll learn how to set up a multiplayer environment, synchronize game objects across the network, handle player connections, and much more.
Photon is a tool that helps games connect players together over the internet.
It's like a bridge that lets players from different places play together in the same game.
With Photon, you can make multiplayer games where players can interact with each other in real-time.
First, you need to have Unity installed on your computer.
Then, you'll add Photon to your Unity project. You can do this by downloading and importing the Photon Unity Networking (PUN) package from the Unity Asset Store.
Once imported, you'll see Photon's scripts and folders in your Unity project.
Before you can use Photon, you need to sign up for a Photon account. It's free to sign up.
After signing up, you'll get an "App ID" from Photon. This ID helps Photon recognize your game when it's running.
In your Photon account, you'll create a new "application" for your game.
Here, you'll use the App ID you got earlier to connect your game to Photon.
Photon uses the concept of "rooms" for multiplayer games. Think of rooms as different spaces where players can play together.
Players can join existing rooms or create new ones.
Each room can have its own rules and settings.
To create multiplayer gameplay, you'll need to synchronize actions between players.
Photon provides methods for sending and receiving messages between players. For example, when a player moves their character, that movement needs to be sent to all other players in the same room.
Before releasing your game, it's essential to test it thoroughly.
You can test your game locally in the Unity Editor by running multiple instances of your game or by creating an android build.
Once you're satisfied with your game, you can build it for different platforms, such as PC, mobile, or consoles.
When building your game, make sure to include Photon's settings and configurations.
Finally, you can publish your game for others to play and enjoy!
In Photon Unity Networking (PUN), the server acts primarily as a messenger, relaying messages between clients. PUN does not provide server-side logic execution, and developers must handle game logic on the client-side. Here's a bit more detail on how this works:
In PUN, each client runs its own instance of the game logic. This means that player actions, such as movement or interactions, are typically processed directly on the client where the action originates.
The Photon server acts as a relay, forwarding messages between clients in the same room.
When a client sends a message to the server (e.g., "Player A moved to position X"), the server broadcasts that message to all other clients in the room, so they can update their own game states accordingly.
Since the server doesn't execute game logic, it doesn't perform validation checks on player actions.
This means that, by default, clients are responsible for validating their own actions. For example, if a player tries to move their character through a wall, the server won't prevent it; it's up to the client to check for such invalid moves and handle them appropriately.
Because client-side logic can't be fully trusted, developers need to implement additional measures to prevent cheating.
Common strategies include server-side checks for suspicious behavior, anti-cheat software, and encryption to protect sensitive data.
In summary, PUN focuses on managing network communication and synchronization, while developers are responsible for implementing game logic and ensuring the integrity of player actions on the client side. It's essential to design your game with this client-server architecture in mind and implement measures to maintain fairness and consistency across all players.
Please read => Part 2 for further exploration of Photon Unity Networking features and implementation details.
I hope you found this blog post enjoyable!