No video

Multiplayer Game In Unity with Firebase tutorial! (all platforms w/ Realtime/Auth & Cloud Functions)

  Рет қаралды 10,195

uNicoDev

uNicoDev

Күн бұрын

Today I'll show you the capabilities of Firebase by creating a Multiplayer game in Unity using services like Realtime Database, Authentication & Cloud functions! This setup will allow for secure matchmaking & turn-based multiplayer between users for all platforms and little to no cost!
Leave a like if you enjoy these sorts of videos and let me know what I should do next!
- - - - - - - - -
- Check out this tutorial's code on Github: github.com/rotolonico/Unity-F...
- Download this video's slides: drive.google.com/file/d/15wg8...
- - - - - - - - -
Mentioned videos
- Firebase SDK In WebGL: • Adding Firebase SDK In...
- Unity coroutines tutorial: • How to run code after ...
- Firebase Authentication tutorial: • How to set up Firebase...
- Firebase Cloud Functions tutorial: • Firebase Cloud Functio...
- Firebase Realtime Rules tutorial: • Firebase Rules Tutoria...
- - - - - - - - -
Chapters:
0:00 Intro
0:59 Why use Firebase?
3:50 Demonstration time!
9:12 Client/Firebase communication
11:35 Supported platforms
13:21 Project structure
17:40 Let's make a move!
20:36 What are coroutines?
24:22 Error handling
26:17 Let's listen for a move!
31:05 User authentication
34:22 Backend code!
36:41 The queue
38:13 Matchmaking
40:42 What are transactions?
45:07 Ready-up
46:21 Processing a move
48:22 Securing our database!
52:38 Let's recap!
53:40 Outro
- - - - - - - - -
- Join my coding discord: / discord
- Music used in the video made by Elektronomia
#unity #firebase #multiplayer

Пікірлер: 26
@simple_6230
@simple_6230 Жыл бұрын
Thank you so much Nico! I like your video and you are a great teacher!
@srigjksefjlsgkd
@srigjksefjlsgkd Жыл бұрын
keep it up ! I got alot of ideas with help of ur techs!! best thanks man.
@5445jedi
@5445jedi Жыл бұрын
Nico, I think that your explanations are thorough and great but I have a hard time focusing with the background music. I would prefer that there would be no background music at all because it's distracting to me.
@FiBunnyCci
@FiBunnyCci Жыл бұрын
Questo canale è bellissimo
@hieptranngoc2584
@hieptranngoc2584 4 ай бұрын
thanks
@joerideman
@joerideman 8 ай бұрын
Thanks for the video. From looking at your video I do not understand the waiting for move mechanism. Is the gamemanager polling the firebase server at an interval? Or does it make a request and then wait indefinitely for an answer?
@urosstojanovic9725
@urosstojanovic9725 Жыл бұрын
Great video, one question. How would you add a timer, lets say user has 15 seconds to make a move?
@uNicoDev
@uNicoDev Жыл бұрын
Great question! So in the make a move cloud function you could have the function also store the move timestamp on the database... And then, before each move, check if that timestamp is older than 15 seconds... On the client side you could just have a local timer....maybe make the cloud function timer slightly longer so it's more forgiving to laggy players... If a player runs out of time the other player could send a request to another cloud function that could verify it's true and end the game (it's better that the other player or both do it so if the first one timeouts the game doesn't soft lock)
@spolmy95
@spolmy95 Жыл бұрын
How do you handle players losing connection? I.e. in a 1vs1 multiplayer game where a lost connection from either player should result in game ending?
@uNicoDev
@uNicoDev Жыл бұрын
You could add a move timer and if it expires without that player making a move, then end the game (I wrote a comment below on how to do it with this set up). If you don't want to implement a timer in your game, you could have a hidden 'ping' that every player has to do every 15 secs or so that is set up in the same way Edit: here's the comment Great question! So in the make a move cloud function you could have the function also store the move timestamp on the database... And then, before each move, check if that timestamp is older than 15 seconds... On the client side you could just have a local timer....maybe make the cloud function timer slightly longer so it's more forgiving to laggy players... If a player runs out of time the other player could send a request to another cloud function that could verify it's true and end the game (it's better that the other player or both do it so if the first one timeouts the game doesn't soft lock)
@spolmy95
@spolmy95 Жыл бұрын
@@uNicoDev thats a very good suggestion, thank you!
@studiomalaka
@studiomalaka Жыл бұрын
Ciao Niko! If you want to experiment with something different than firebase that offers most of its features in a lightweight open-source solution, for my current Unity project I'm leveraging kinto-storage. I'm very happy so far, open to share more if interested
@uNicoDev
@uNicoDev Жыл бұрын
Hey! Currently in my production projects we are using Firebase and it would not be easy to migrate but it could be an interesting topic for a video to compare the two services, so I'd be interested to know more as I have not heard of this alternative before
@studiomalaka
@studiomalaka Жыл бұрын
@@uNicoDev I'll PM you on Discord ;)
@WelshGuitarDude
@WelshGuitarDude Жыл бұрын
Whats the pricing like compared to firebase?
@studiomalaka
@studiomalaka Жыл бұрын
@@WelshGuitarDude it's a self hosted solution from the Mozilla foundation, 100% free and open-source
@WelshGuitarDude
@WelshGuitarDude Жыл бұрын
@@studiomalaka sounds stress if by luck your app goes viral with a million installs though
@carras5497
@carras5497 Жыл бұрын
why when i deploy the index file under every function in the cloud panel says us-central1 if i created the database in europe? thanks
@uNicoDev
@uNicoDev Жыл бұрын
Looks like you can change the region where your cloud function is located in the code itself by doing ".region('europe-west1')" when you invoke it, at example. Got it from here: firebase.google.com/docs/functions/locations#web
@carras5497
@carras5497 Жыл бұрын
@@uNicoDev Thanks!!
@kazimashiatsumaira1684
@kazimashiatsumaira1684 4 ай бұрын
I am confused. How did you signal other player from within the game that you want to join his room? There was no reference for the connection between them like a same id or room name being shared so one can join his friend's game and not a random player's
@uNicoDev
@uNicoDev 4 ай бұрын
So if you check out this video's code in the description, in the MatchmakingManager.cs, it is actually listening on a node when the userId is in the queue and the cloud function will 'match' players together by adding the gameId as a children of the node that the two players are listening to: github.com/rotolonico/Unity-Firebase-Multiplayer-Example/blob/v2/Assets/Scripts/Managers/MatchmakingManager.cs
@Jeyck
@Jeyck Жыл бұрын
Where are you from?
@akosdanielbollok4956
@akosdanielbollok4956 13 күн бұрын
The problem with your approach is firebase unity sdk on desktopis for development purposes only and shouldn't be used in builds as of today. => Firebase auth has no support for native desktop unity games
Firebase Rules Tutorial for your Realtime Database! [PART 1]
21:16
Magic trick 🪄😁
00:13
Andrey Grechka
Рет қаралды 25 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 16 МЛН
👨‍🔧📐
00:43
Kan Andrey
Рет қаралды 7 МЛН
Getting started with Firebase in Unity (2019) - Firecasts
12:54
Custom 2D Game Engine Devlog 2
27:36
Jordan Grant
Рет қаралды 662
Adding Firebase SDK In Unity WebGL builds!
25:21
uNicoDev
Рет қаралды 21 М.
Seth Meyers Catches Up on the Worst Three Weeks of Donald Trump's Campaign: A Closer Look
15:50
Multiplayer Game Architecture in Unity
15:21
Shrine
Рет қаралды 152 М.
Unity User Login System Tutorial - Firebase Authentication
14:07
xzippyzachx
Рет қаралды 111 М.
Magic trick 🪄😁
00:13
Andrey Grechka
Рет қаралды 25 МЛН