How Photon for Unity Works

Опубликовано: 15 Июль 2019
на канале: Zenva
11,719
241

ACCESS the FULL COURSE here: https://academy.zenva.com/product/mul...

TRANSCRIPT

Hey everyone. In this lesson, we're gonna be talking about multiplayer in Unity and Photon, and have actually work in all different things that you really need before we actually get started. So the firs thing is what sort of multiplayer is there in Unity? Well, Unity used to have their own multiplayer network. If you're watching this course some time around early 2019, then you UNet which is Unity's old Unity Networking framework, it is now deprecated. So we won't be able to use that. Instead, we're gonna be using Photon. And Photon is the most popular Unity multiplayer framework. There are many popular games that use it, and it's easy to use. If you've ever used UNet before, it's basically the exact same thing, but with added features. Alright. So, how does multiplayer work? Or what it is we have multiple players connected together, and what they do is at its core, a multiplayer is basically just sending messages between computers. So, let's just say player one here moves forward one unit, then that commend or that actual new position of the player will be sent from the player, from player over through the server to player two. So, on player two's screen, player one is not one unit or at their new position. And so, that's how it works. You'll be sending various amounts and messages every second. By default, I believe that Photon sends about 20 messages per second. You can of course tweak that, but it's set at 20 to be nice, so it doesn't have too much lag or too much problems with that. So yeah, that is at its core, is sending messages between computers. Let's just say you wanna do an attack. You cast the attack on your computer, and then you send that message over to player two's computer, so if there are any visuals that go with that attack, those visuals can be displayed on their computer. And that is how you sync between computers, sync between states, positions, rotations, everything that you want to appear on other people's computers, that is how you do it, through messages. And we'll be going to some more detail on how to actually do this in code and in script, and also with Unity's components, what stuff you need to set up, and all of that stuff in later lessons. So the first concept we need to go over is a master server. What is a master server? Well, in Photon and even in Unity networking, a master server is basically connection of rooms. I'll go over rooms in a second. Players can connect to rooms, and there you can see a list of all the rooms. It's basically like a sort of hub for your game. And each game has their own specific master sever, and even different versions of your game. You can specify it to have different master servers. So, if you're on version one of your game, you can't play with people who are on version two, for example. And of course, if you have your game, you can't play with people who are in other games. You can only play with people on your game in your specific version of that game. And the good thing about Photon is they have their own dedicated hosted servers all around the world. As you can see to the right, there are many locations around the world where you can basically connect your master server and your game to. In Photon, you can also do it so that for players it connects to the master server with the lowest ping. So you can try and always have the lowest ping possible, or you can just hard code it, so that you connect to a specific master server. Players on different master servers cannot play with each other. So you do need to keep that in mind when making your game. And of course, with Photon, it is a service that you can choose to pay more to increase the capacity of the server. By default, your game can have up to 20 players at once with the free version of Photon, but you can of course pay for more, and yeah. Of course, you can also host your own server if you wish. That will of course require you to have your own server hardware setup and have all of the networking capabilities available.


Смотрите видео How Photon for Unity Works онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Zenva 15 Июль 2019, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 11,719 раз и оно понравилось 241 людям.