- Tubelator AI
- >
- Videos
- >
- Education
- >
- Building a Multiplayer Game with Fusion 2: Connection & Basic Movement | Part 1
Building a Multiplayer Game with Fusion 2: Connection & Basic Movement | Part 1
Learn how to make a multiplayer game in Unity using Photon Fusion 2. Follow this tutorial series to create a first-person parkour racing game with unique abilities like grappling hooks and player interactions. Part 1 focuses on setting up connections, implementing basic movement, and accessing essential downloads.
Video Summary & Chapters
No chapters for this video generated yet.
Video Transcript
Welcome to part one of this new tutorial series where we'll be using Photon Fusion 2 to build a multiplayer game in Unity.
If you haven't heard of Fusion before, it's basically a high-performance networking library which makes building multiplayer games in Unity simpler and more approachable.
By the end of these tutorials, you'll have built a first-person parkour racing game where your goal is for players to be the first one to reach the top of the course.
To help you achieve this, you have a grappling hook, the ability to shove or temporarily immobilize other players, and several other abilities.
In this first video, we're just going to set up the connection and implement basic input sampling and player movement.
While we're going to build all the mechanics and write all the game-related code in these videos, we will be starting from a starter project, which you can download from the Photon website.
You can also find downloads here for the state that the project is in at the end of each video.
The link to this page will be in the description, but note that you'll need a Photon account
to access the download.
Once you've downloaded the starter project, open it up, ideally with Unity 2022.3.19.
Inside, you should find Fusion pre-installed, along with the simple and advanced KCC addons
and the Fusion menu.
The various materials, basic prefabs, sounds, and other assets which we'll be using throughout
the series are also included.
In the main scene, you'll mainly see a bunch of UI elements, including the Fusion menu.
The game scene is pretty much empty, aside from a light, a post-processing volume, and a big plane for the ground.
Now first things first, you're going to need a Photon Fusion app ID.
To create one, go to your Photon dashboard and then click Create a New App at the top.
Make sure a multiplayer game is selected, choose Fusion as the SDK, and make sure the SDK version is set to Fusion 2.
Give your app a name and click create.
I already have an existing app ID so I'm going to cancel this one.
Once your app is created, copy the app ID and go back to Unity.
Open the Fusion Hub from the Tools-Fusion-Fusion Hub menu and paste your app ID into the text box.
you should see a green checkmark appear next to it.
With that taken care of, we can now set up the connection.
To do this, create a runner prefab and attach the network runner script to it.
Then find the menu game object in the scene
and assign the runner prefab to the menu connection behavior scripts field.
At this point, we could already run the game and create a room through the menu,
which would then instantiate a runner from the prefab we just gave it,
but there wouldn't be anything to see or do in it, so let's spawn some players.
Create a Player script and a GameLogic script.
For now, we're just going to remove the Player class's default Unity methods and make it inherit from NetworkBehaviour instead of from MonoBehaviour.
Our GameLogic class also needs to inherit from NetworkBehaviour.
NetworkBehaviour is something you'll use frequently when developing with Fusion, as it handles network properties and RPCs,
and provides a bunch of useful callbacks and other functionality which we'll be using throughout this tutorial series.
Next, add a network prefab reference for our player prefab.
We'll also need a network dictionary to keep track of players that connect, and we'll give
it the networked attribute to make it a network property.
This basically tells Fusion to replicate the property's value from the server or host client
to other clients.
The capacity attribute sets the absolute limit on the dictionary's capacity, and this can't
be changed at runtime.
I've set it to 12 because that's what I've set as the maximum number of players in the
Fusion menu config.
Next, we need to spawn players when they join and despawn them when they leave, which we'll
do by implementing the iPlayerJoined and iPlayerLeft callbacks.
To ensure that only the host initiates the spawning of players, we're going to check
if we have state authority before using the network runner's spawn method to instantiate
our player prefab.
Video Summary & Chapters
No chapters for this video generated yet.
Video Transcript
Bu yeni tutorial serisinin ilk kısmına hoşgeldiniz.
Burada, Foton Fusion 2'yi Unity'de bir multiplayer oyun yapmaya çalışacağız.
Fusion'u daha önce duymadığınız için,
bu basit bir yüksek performans netflik librasi,
bu, Unity'de multiplayer oyunları yapmak daha basit ve yakınlaşabilir.
Bu tutorialleri bitirince,
ilk kişi parkur ya da yürüyüş oyununu yapabilirsiniz
ve oyuncuların amacı, ilk kişinin kursunun üstüne ulaşmasına.
Bunu yapmak için yardımcı olduğunuz için,
bir kutu var, diğer oyuncuları tembellendirme veya tembellendirme yapabilmek
ve birçok diğer yetenekler.
Bu ilk videoda, sadece bir bağlantı kurmak ve basit input samplaması ve oyuncu hareketlerini implementetmek için yapacağız.
Bu videoda tüm mekanikleri yapıp, tüm oyunla ilgili kodları yazacağız.
Başlangıçta başlayacağız, Foton'un web sitesinden doldurabilirsiniz.
Ayrıca, bu videonun sonuncu bölümünde olan projenin kuruluşu için doldurulabilirsiniz.
Bu sayede link var, ama doldurulmak için Foton'un hesabını almanız gerekiyor.
bir sonraki videoda görüşürüz.
3.19. İçerisinde Fusion'u pre-installed'a katılmalısınız,
KCC adonları ve Fusion menüyü ile birlikte.
Tüm materyallar, basit prefabler, sesler ve diğer asetler
serisinde kullanacağımız olanlar da var.
Kulaklıkta, en önemli şey, UI elemanları,
Fusion menüyü de var. Oyun kutusunda,
ışık, post-processing volümü ve
bir büyük uçak var. Şimdi ilk olarak,
İlk olarak, Fusion App ID'yi kullanmanız gerekiyor.
Birini kurmak için, Foton Dashboard'a git ve
yeni bir app'i çevirmenin üstünde kliklayın.
Multiplayer oyununu seçin,
Fusion SDK'yi seçin ve
SDK versiyonunu Fusion 2'ye koyun.
App'i isim verin ve Çevir'i kliklayın.
Ben zaten bir existing App ID'yim var,
bunu kutlamak için çalışacağım.
App'iniz kutulduğunda,
App ID'yi kopyaladığınızda,
Unity'ye geri dönün.
Fusion Hub'ın Tools-Fusion-Fusion Hub'ın
ve App ID'ni text box'a koy.
Yerde bir ışık görmelisin.
ve bir şeklik ortaya çıkıyor.
Bunu yaptıktan sonra,
şu an bağlantıyı hazırlayabiliriz.
Bunu yapmak için, runner prefabı
ve netflik runner script'i ona takip edin.
Sonra, scene'deki menü oyun cihazını bulup,
runner prefabı menü bağlantı
behavior script'e takip edin.
Bu anda,
altyazıda alışkan bir yer