Main

Unity : How to use Steam Multiplayer in Visual Scripting

πŸ’¬ Turn on [CC] to translate to any Languages [JP/FR/GR/EN/VI/CN/KR/ES... all supported] 🎬 Tutorial part 1 : How to use Netcode in Visual Scripting : https://youtu.be/KZdmbGXTj4Y?si=x37QTEc9DGHYagvF ⭐ This Video : How to build a complete P2P Steam Lobby in Unity Visual Scripting . Install plugins . Macro Steam Network . Step 1 Create Lobby . Leave Lobby . Test Create Lobby . Step 2 Search Lobby to join in . Need 2 PCs to test . Step 3 Join in lobby . Test Join in lobby . Disconnected? Reconnect it . Test Client Reconnect . Host disconnected ? . Transfer new Host . Get Lobby info . Test Host Reconnect . Example script === πŸ€ New in Unity ? Dont know how to code ... Dont worry Learning Path for you : 🐾 Level 1 : Learn Unity basic in 2D game - For Beginner (all script and resource are FREE ) : https://youtube.com/playlist?list=PLcNb7VR72tXP1Mqcd-vXnn_F6MJE-bbCP 🐾 Level 2 : Learn Unity basic in 3D game - All videos (all script and resource are FREE ) : https://youtube.com/playlist?list=PLcNb7VR72tXM_3eXrVMxutYa4E-YIJnOa&si=V4VL3VWB4ASR-bsW 🐾 Level 3 : Learn Unity basic 3rd Person game or 1st Person game (all script and resource are FREE ) : https://youtube.com/playlist?list=PLcNb7VR72tXOeGUBznVOPlJ60zQCMesIN 🐾 Level 4 : Learn to use C# in Visual Scripting : https://youtube.com/playlist?list=PLcNb7VR72tXOSmzBsUsWCNizzWKmdyxR7&si=lioHEIv1GTsrI-gC ( videos explain all basic C# code soon... ) 🐾 Level 5 : Make Multiplayer Online game with Netcode in Visual Scripting : https://youtube.com/playlist?list=PLLYnL37vQ02SYU-N_VpHrhG87qjlNhlPl&si=no4cIUPr8uqinAuM ===== πŸ”₯ Download Visual Scripting Plus from Unity Asset Store to support me: https://assetstore.unity.com/packages/slug/219926 ===== πŸ‚ Any questions about Unity or Visual Scripting : https://discord.gg/MsmQ64rX9y ( me @Leo69 ) Follow me at : - Instagram: https://www.instagram.com/leonnguyen0609/ - TikTok: https://www.tiktok.com/@leonng_333 - Twitter : @unitynocode - Fb : unitynocode #madewithunity #visualscripting #gamedev #gamedevelopment #nocode #unitynocode ===== Chapters 0:00 - Intro 0:55 - Install plugins 2:23 - Macro Steam Network 3:17 - Step 1 Create Lobby 5:35 - Leave Lobby 6:08 - Test Create Lobby 7:04 - Step 2 Search Lobby to join in 9:01 - Need 2 PCs to test 9:54 - Step 3 Join in lobby 11:11 - Test Join in lobby 11:55 - Disconnected? Reconnect it 14:11 - Test Client Reconnect 15:00 - Host disconnected ? 15:48 - Transfer new Host 17:21 - Get Lobby info 18:58 - Test Host Reconnect 20:17 - Example script

Unity No Code | Leo N

2 weeks ago

In last video: I showed you how to use Unity Lobby to connect Player to Player But actually, Unity Relay & Lobby is not free 100% and the speed kindly slow So today, I will show you how to create online game on Steam with completely FREE relay and lobby with the Ping, is a lot better and very easy to use it too All events of a game just in 1 this photo only Create new Lobby in 1 node "Search Lobbies" with matching system in 1 node Join in Lobby in 1 node ... and even "Reconnecting" in 1 node als
o Support reconnecting ... even Host is disconnected Next Client will be a new Host to connect all other Players Tittle : Install Plugin First : make sure you updated Visual Scripting Plus to the newest version and import all things from it to your project After that you will receive folder "Macro-Netcode" we used in video Part 1 You will receive folder "Macro-Steam Network" open this file to see "How to use" it First: you need to install "Macro-Netcode" that we already did in video part 1 in th
is video : you will need plugin "Steamwork Facepunch" to work with You can get it free with link here, or from any link from github After download, just add it to your project and it's ready to use After downloading, you will receive this folder ... add it into your project Now open "Macro-Steam Network" Unzip this folder to get scripts to use From this step : it will be exactly the same all steps in Unity Lobby video After all, we need to Restart Unity for all script to reload Everything is rea
dy now ! Tittle : Macro - Steam Network Open Use-SteamNetwork to get events to use We have some instruction How to use it Step by step here It required Installing Netcode and Steamwork, that we did already You need to put prefab of "Macro-Steam Network" into Hierarchy to start it This is prefab "Macro-Steam Network"... add it into We don't need "Macro-Unity Lobby" any more. Delete it ! Make sure you have "Macro-Netcode" and "Macro-SteamNetwork" here This is "Player Controller" that we made in vi
deo Part 1 ... How to move Player on Host and Client We will not touch anything here on "Macro-Steam Network" This is Protocol Transport used in Steam "Steam App Id" is your Game ID on Steam ID : 480. is the Free Game that you can use to test Steamwork functions Tittle : Step 1. Create Lobby Open Use-Steam Network Open Use-Steam Network Step 1 : You need to create a Lobby or Game Room for others to join your game Step 1 : You need to create a Lobby or Game Room for others to join your game There
is a Step 0 here ... This event will sign in to Steam account to get your Steam ID to use it here It might take 1 seconds, and you can just ignore it if you want I will ignore Step 0, and go to Create first Lobby directly just copy to use it First : create a new Empty Object name it "Steam Manager" add new Visual Scripting script with any names you like open it paste the copied event here After clicked on "Button Create Lobby", let's create a Lobby Create a Button Click event "On Pointer Down"
for Click down Let's add "Button Create Lobby" into If Button is clicked, a Lobby will be created ... "Max Player" is the total Players can join in Lobby and your game Password to join if you want to use password If you turn on "is Private" box ... Your game room will not be showed on searching list ... But Player can still join in with your Lobby ID Search Region for Location setting ... I'm in North America currently, I will enter "NA" ... or you can type Asia or any locations you like ... thi
s option for Players in same Location can match games with each others to reduce the Delay or Lag between Host and Clients "Search Lobby Name" can be used to look for your Friend's Games Example : I will enter my name "Leo Room" Add "Game Mode" if you want : Free Mode or Rank Mode and limit Level of Player can join in your room ... I will give you more example later After Lobby is created successfully. Let's display that Lobby Name Lobby ID and password ... to see how it works Tittle : Button Le
ave Lobby Before to test it. Let's add Button to "Leave Lobby" also Create 1 more Button Click event change name it "Button Leave Lobby" open "Use-Steam Network" Copy event "Leave Lobby" After click "Button Leave Lobby", Player will leave that Lobby Print a message "Left Lobby" after it Tittle : Test Creating Lobby Press Play to see how it works click "Button Create Lobby" A Lobby was created succefully ! We can do it with just 1 node only. Very simple, right ? You can know what the Lobby Name ,
Lobby ID Password and is it a Private room ? If you click "Button Leave Lobby" You will leave that Lobby immediately All connections between Host and Clients will be disconnected Let's create another Game Room with some Password ... and turn on "Private" room click "Button Create Lobby" again new Lobby is created It will have another Lobby ID, password... and now is Private Tittle : Step 2. Search Lobby to join in open "Use-Steam Network" again Let's go to Step 2 Now another Player click on But
ton "Join" or "Auto Join" ... We need to check if he was disconnected from any Game Room ? to reconnect him back to that game ... I will ignore this ... and do it later Instead that : let's "Search Avaiable Lobbies" to join in Let's copy this event to use ! Open our script paste copied event here create click event for "Button Join" I created "Button Join Lobby" already After "Button Join Lobby" is clicked, it will do "Search All Lobbies" can join Max Result is total Lobbies you can get on the L
ist "With Region" is the Filter to match your Location in step 1, I created my Lobby in "NA" , for people North America to join in to be able to find my Lobby, it should search for "NA" region only type Lobby name to find Lobbies with this name only... this Matching system is so simple to use... I will show you with test later After it's done... You will have all "Available Lobbies" that you can join in If the Lobbies are found ... the number Lobbies will be greater than 0 Let's print the number
of "Found Lobbies" to Debug.Log to see the result If "Found Lobbies" > 0, let's join in one of those Lobbies Tittle : Another Computer for 2 Steam Players This is my 1st Steam account on the 1st PC and this is my 2nd Steam account on 2nd PC You will need 2 seperate PC to be able to test Multiplayer game on Steam copy all your project to the 2nd computer... This is all things we just made in the 1st PC Now press Play to test it out ... on 1 PC, press "Button Create Lobby" A Lobby was created ...
you can watch its Lobby ID to check it On 2nd PC, press Play click "Button Join Lobby" You can see, it can find a Lobby that was created from another PC Tittle : Step 3. Join in A Lobby Open script "Use - Steam Network" After you searched and found some Lobbies ... you can join it now with event "Join Lobby with ID" After joined in a Lobby, it will start Host and Client to connect them copy this event to use it By the way, the List you received after Searching ... with each item in this List wi
ll be "A Lobby" So we can use this event to get "Lobby ID" from [A Lobby] of the List I will copy "Join in..." event with "A Lobby" event too paste them here Let's pick random "A Lobby" from the List of Lobbies this item will be [A Lobby] We can use this event to get "Lobby ID" from [A Lobby] After have a "Lobby ID" you want to join ... Add it into event "Join Lobby with ID" to join in this Lobby Tittle : Test [ Join in Lobby ] On 1st PC : Create new Lobby and on another PC ... click "Button Joi
n Lobby" It found a Lobby ... and joined in to this Lobby the Lobby ID is the same with Lobby ID of 1st PC The Ping is good Steam has the connection a lot faster than Unity Lobby.... and Free Relay , Free Bandwidth data completely 100% I recommend to use Steam at this moment to make game online... Tittle : Disconnected? Reconnect it... Before you join in or searching any Lobbies... You need to check if this Player was disconnected from last game or not ? If TRUE : just call [Lobby Reconnect] to
reconnect him back to the game We have events to check his reconnection here ... Let's copy 2 these events open our script As instruction, we should check it before do "Searching Lobbies" paste them here After click "Button Join", let's check if Player is disconnected from last game? If he was not , just do Search Lobbies and Join as normally and If he was disconnected , we need to call [Lobby : Reconnect] After he reconnected back to his game, it will trigger Success If reconnect failed, you ca
n do Search Lobbies again and Join another game That's it ! Very simple right ? Tittle : LOCK Lobby ! For Players to be able to reconnect back to the game ... It required that Lobby must be "Locked" We have event "Lock Lobby" here. Copy it ! Open our script Put it anywhere you want Create Button click for "Button Lock Lobby" We need to add the Lobby ID into You can get the Current Lobby ID that Player has joined here add it into Make sure you check this True to LOCK it I have a Text object here,
to show message on the screen After Lobby is locked, let's print out some Message on screen to know it Tittle : Test Client Reconnect ! Copy all the script to your 2nd Computer and test it On 1st PC : Create a Lobby On 2nd PC : get Player search and join in our lobby 2nd Player has joined in Now : Let's LOCK the current lobby to start the game ... While the game is playing ... Player 2 suddenly has been disconnected ... And after awhile, he is back to game ... Now if he clicked on "Button Join"
He can reconnect back to his game Because the game is still playing and Host is still there Player 2 has been reconnected successfully ! Tittle : Host disconnected? Reconnect Client is super easy ... How about if Host is disconnected ? When Host is disconnected... All Clients in this Lobby will be kicked out of the room and disconnected also When Host is disconnected, we have 2 choices here : "Can Host Reconnect ?" If you select "Can Host Reconnect" , is False : After Host disconnected, all Cli
ents will be disconnected also And if you selected "Can Host Reconnect" True ... Next Client will be the New Host all other Clients and old Host will be reconnected to this New Host for the game can keep playing Tittle : Transfer new Host When the Host is left or disconnected This event will be triggered If Transfer new Host is processing ... [Picking New Host] will trigger It will occur when you select "Can Host Reconnect" and the Lobby is Locked After Client has become a New Host, this output
will trigger Other Clients will reconnect to New Host, and this output will be triggered In some reasons, transfer Host or reconnect is failed output "On Quit" will be triggered and the game should be ended Let's copy this event to use Open our script I will put it next to event "Create Lobby" Make sure you selected "Can Host Reconnect" Now if Host is left, this event will trigger Show message on screen to tell that we are "Picking New Host !" After a Client is successful to become a new Host Th
is output will trigger This output will trigger when a Client reconnected to this new Host and if it is failed to reconnect ... You can show some message like this Enemy has surrendered and You win Most of popular Online Games they do the same thing ... Tittle : Get Lobby Information Before running the test, let's check how many Players in Lobby and their info Whenever a Player joined in or has left, this Lobby information will be updated and we can use this event to see Members ID in this Lobby
and how many Available Slots has left Alright. Copy 2 of these to use Open our script Paste it anywhere you want Button click event to get Lobby Information I created "Button Get Lobby" to get the current Lobby information copy its name into After Button is clicked, let's print out all Members Steam ID in this Lobby and print out the total of "Available Slots" currently We have finished everything we need in 1 Multiplayer Game Ass you see, it's very simple Tittle : Test Host Reconnect ! Copy th
e script to all 2nd and 3rd computer to test On 1st PC : we create a Lobby and become a Host If you click on "Button Get Lobby" information All members in Lobby currently will show up On 2nd PC : get Player to join in random lobby and 3rd Player will join in as well Let's check current Lobby information again ... We have 3 Players in this Lobby already For Players can reconnect if they are disconnected ... We must LOCK the lobby first... to start the game ! Now while the game is playing ... Host
suddenly disconnected Watch on 2nd PC : it became to a New Host right away and 3rd PC : he reconnected to New Host as a new Client as well Transfer new Host is successful ! Now old Host was back to the game ... He will reconnect to the previous game as a new Client Same as event "Client Reconnect" we did earlier The total number Players in this Lobby is 3 now... All Players were reconnected back to the disconnected game ! Tittle : Example Script You can find the exactly script in this video in
folder "Macro - Steam Network" Put this script into and press Play... It will work immediately If you have any questions, please let me know with comments ... Thank you for watching !

Comments