Basics of Multiplayer in Godot 4! C# Godot Basics!

  Рет қаралды 15,949

FinePointCGI

FinePointCGI

Күн бұрын

Пікірлер: 56
@samu3lp88
@samu3lp88 Жыл бұрын
Its nice if you use Rpc(nameof(startGame)) instead of Rpc("startGame") so you dont have to rely on hardcoded method names, and if u eventually need to change the method name you don't need to worry about changing strings in the code. When using nameof you can also use IDE tools, such as finding method references, etc.
@FinePointCGI
@FinePointCGI Жыл бұрын
I didn't know that existed. That's really cool thanks!
@axvemi
@axvemi 8 ай бұрын
You call also do Rpc(MethodName.StartGame), you also have this for signals (SignalName.Pressed) for a button, for example
@praktix8992
@praktix8992 2 ай бұрын
for everyone using GD 4.2 and still struggel to find the Build Button: Its now the little Hammer Symbol :)
@ModernArtery
@ModernArtery Жыл бұрын
This is a great tutorial. I ran into an issue testing external network connections over the Internet. Turns out that my router wasn't allowing me to "connect to myself" over the Internet, but when I got a friend to test from an actual external network location, it worked totally fine. Having fixed that problem, it seems to me that pretty much everything shown in this video is accurate and working in the current version of Godot 4.
@FinePointCGI
@FinePointCGI Жыл бұрын
Hey I'm glad it worked for you!
@nemanjastefanovic990
@nemanjastefanovic990 Жыл бұрын
First of all thanks for the great tutorial, it was really useful right till the end where you explain how to host the game on DigitalOcean. I have newer hosted a game and was wandering could you show us how to use your droplet since I am not shore i would like to pay for hosting just to test the game with a friend or two :( Huge thanks in advance!
@v44n7
@v44n7 Жыл бұрын
oh this is amazing! I have tested some multiplayer in godot in a 3D project that I am working on. I was surprise how easily it was to set everything up. the server, the client side. I even used rcp calls to gain skill info from the server and that kind of stuff. Sync of movement was an issue and I dropped multi after that test. I still need to figure many other core mechanics of my game before bothering with multiplayer but still. Godot has huge potential on it for sure. Thanks so much for this tho! gonna for sure check it!
@FinePointCGI
@FinePointCGI Жыл бұрын
That's one of the coolest things about Godot multiplayer is relatively easy. Non-server multiplayer WebRTC is quite a bit more complicated but it is easier than other engines that's for sure!
@mannig.faltigkeit2341
@mannig.faltigkeit2341 10 ай бұрын
What is the thing showing your inputs (mouse clicking, arrows) during the video? Also: Thanks for not editing out the pitfalls, this is the stuff where one actually learns something.
@smurflover3537
@smurflover3537 3 ай бұрын
thats just the IDE (the environment he`s working in), in this case its vscode, however most of the ide`s will offer you similar tools
@AzzuBananas
@AzzuBananas Жыл бұрын
Amazing video! I learned a lot about multiplayer thnks a lot! Actually i think the multiplayer in the same project can be better if we manage it in an Autoload in that case the system will let us change between scenes without problem. IDK if I'm right but it's just an idea And i have a question, is it hard to make a server for our game that doesn't contains the game? Sometimes i make Minecraft servers, and the file of the server is no the same as the game i think it works to let all the users mount their own servers and make an exe lighter than the game I guess, if u have an idea can u explain it? And one more question, is any way to send args to our project inside Godot? to play the server without export it?
@meezi2987
@meezi2987 Жыл бұрын
Please make tutorial for multiplayer 3D 🥺 I haven't seen any video's on KZbin about this
@nemanjastefanovic990
@nemanjastefanovic990 Жыл бұрын
You can use this tutorial if you know how to make basic 3D game. I have followed this using 3d project and only issue I ran into was players stealing each others cameras(since I did first person muliplayer) and i fixed it with camera.Current = true, so I don't think you would run into many problems either!
@Josh-op6dl
@Josh-op6dl 3 ай бұрын
​@@nemanjastefanovic990 I was trying to make it but I struggle to do it, so here is further information: You need to create a new script for the player camera and add this piece of code: func _process(delta): if $"../MultiplayerSynchronizer".get_multiplayer_authority() == multiplayer.get_unique_id(): make_current() (Sorry for it being in gdscript, I don't know C#, I was here loking for the solution of the gdscript tutorial) # Credits to Balki_i on the Godot official forum.
@Josh-op6dl
@Josh-op6dl 3 ай бұрын
@@nemanjastefanovic990 here's further information on how to follow this tutorial in 3d: You need to create a new script for the player camera and add this piece of code: func _process(delta): if $"../MultiplayerSynchronizer".get_multiplayer_authority() == multiplayer.get_unique_id(): make_current()
@Lui-._.--
@Lui-._.-- 8 ай бұрын
Very nice Tutorial, but I have a question. I want to test the game from computers in diffrent LANs, so the IP Address must be public. First i write my global, unique IPv4 address in the export variable Address (Scene Multiplayer Controller). Than I host it first. All seems good. But when I want to join, it didnt find the host. Is it becuase the port on my router is blocked or is it something else?
@FinePointCGI
@FinePointCGI 8 ай бұрын
Correct using this method your firewall is goign to block it.
@DerWenzel
@DerWenzel Жыл бұрын
Nice tutorial. Thank you for sharing! Good multiplayer tutorials are super rare. big problem is they are also often very long. The buttons pressed overlaying use is a bit irritating. A tutorial on basic interaction and / or enemy handling would be nice! Or best practices for node architecture when working with multiplayer.
@FinePointCGI
@FinePointCGI Жыл бұрын
I'm def hit and miss on that overlay.. I'll take a poll and see what people want. I will add them to my list! Can you give me more details on the tutorials?
@goldengoblinX
@goldengoblinX Жыл бұрын
Will you make part two for GDscript?
@FinePointCGI
@FinePointCGI Жыл бұрын
I plan to. Every single tutorial I make I usually do a C# version right after the GD version. For instance I am recording a GD version of a LAN server browser by using udp and ping casting so I'll be making a C# version of it right after. As for a part 2 what would you like to see currently I would like to have a WebRTC multiplayer tutorial but is there anything specific that you want in a part 2?
@goldengoblinX
@goldengoblinX Жыл бұрын
@@FinePointCGI You are awesome, My request is to set up a room and let others join the room with that room name. Can you make it ? Every player can choose their colors those colors are red, yellow, blue and green.
@FinePointCGI
@FinePointCGI Жыл бұрын
@@goldengoblinX I can put it on my list... When it comes to a room usually that means you want to use WebRTC since WebRTC has the capability to build out rooms..
@goldengoblinX
@goldengoblinX Жыл бұрын
@@FinePointCGI You are the best Godot KZbinr in this world 🌍
@gudmo49
@gudmo49 9 ай бұрын
Im at this point of the tutorial 34:17 and i checked my code, apparently its all good, but then when i click play, nothing happens, it seems like is not even detectin when i click the button... someone else with that issue?
@gudmo49
@gudmo49 9 ай бұрын
Nevermind, it was my mistake, i didnt connect the buttons hahaha
@RprtBak
@RprtBak Жыл бұрын
If you want something similar for a top down game, I used this (Also I have my own changes, I have move_ instead of UI and I have MoveSpeed instead of Speed) - Also velocity is normalized so diagonal movement isn't faster: Vector2 velocity = Velocity; Vector2 direction = Input.GetVector("move_left", "move_right", "move_up", "move_down"); if (direction != Vector2.Zero) { velocity.X = direction.X * MoveSpeed; velocity.Y = direction.Y * MoveSpeed; } else { velocity.X = Mathf.MoveToward(Velocity.X, 0, MoveSpeed); velocity.Y = Mathf.MoveToward(Velocity.Y, 0, MoveSpeed); } Velocity = velocity.Normalized() * MoveSpeed; MoveAndSlide();
@jlebrech
@jlebrech Жыл бұрын
could you cover MultiplayerSynchronizer visibility?
@FinePointCGI
@FinePointCGI Жыл бұрын
I want to but the docs are not clear at all how it works so it may take some time for me to figure out how it works..
@jlebrech
@jlebrech Жыл бұрын
@@FinePointCGI exactly, I've bee struggling to find a basic example. was thinking maybe a game of pong but with walls that obscure the ball and the other player.
@joannagrzybek8126
@joannagrzybek8126 8 ай бұрын
Hello:P I spoted some bug... if u set max player to more than 2 players and more than 2 players are connected wierd things start to heppen like players are duplicated and instead of lets say 4 players i am getting 8 spawned... godot shows also error in Player.cs -> E 0:00:25:0541 void System.Number.ThrowOverflowOrFormatException(System.Number+ParsingStatus, System.TypeCode): System.FormatException: Input string was not in a correct format. System.FormatException :0 @ void System.Number.ThrowOverflowOrFormatException(System.Number+ParsingStatus, System.TypeCode) :0 @ void System.Number.ThrowOverflowOrFormatException(System.Number+ParsingStatus, System.TypeCode) :0 @ int System.Int32.Parse(string) Player.cs:18 @ void Player._Ready() Node.cs:2117 @ bool
@joannagrzybek8126
@joannagrzybek8126 8 ай бұрын
I found whats wrong... function sendPlayerInformation is wrong... somehow it duplicates playerInfo for all joining players besides host and last joined player so lets say if there is 5 players then player 2,3,4 are duplicated * number of all players... u can see this by printing item in GameManager.Players when game is running (i dont know why becouse !GameManager.Players.Contains should check if it already exists) so for only 2 clients i seems to be ok but for more players its wrong... i fixed it like this i recoded function that server is storing information about all players and when all are ready then before gameStart server sends all players information to each client when sending is ready then all clients starts game (bug exists only in c# version in GD script all is ok)
@ptronicmusic
@ptronicmusic 6 ай бұрын
I'm getting this too, did you ever find out the bug? On mine when I spawn 3 players (let''s call them A (host), B and C) I get weird behavior. For A and C everything is fine but for B it spawns duplicates of A and B in the center of the map (not a spawn point) and they have a generic name. The name is what the error is talking about because in Player._Ready() it's trying to parse what's supposed to be an int but is instead the generic type name (CharacterBody3D in my case). For the life of me I can't figure out where the GameManager is getting these extra players.
@joannagrzybek8126
@joannagrzybek8126 6 ай бұрын
Yes i found bug and i posted solution... and Day after it was deleted... game manager is ok problem is in send Player information function it is replicating every data betwean first and last Player... my solution was first Connect all players and they send data only to host when all are ready then before startgame i send data to all other clients and iam waiting for answet if Player list is created then start game on every client
@ptronicmusic
@ptronicmusic 6 ай бұрын
@@joannagrzybek8126Wow thanks for the lightning fast reply! I had a feeling there was something there. I will take a look - thank you!
@ptronicmusic
@ptronicmusic 6 ай бұрын
Wanted to leave my solution in case other folks have the same issue. So I'm not sure entirely what was happening but I suspect that the contains check: if (!GameManager.Players.Contains(playerInfo)). Was not working as intended and actually caused the duplication to happen. My fix was to change this check to a LINQ function that checks for the specific id and if it's not found then add the PlayerInfo to the game manager. I'm still pretty new to C# so I don't know if it's the best solution. // This was my solution. I need to come up with a better name for "fromList" 😅 var fromList = GameManager.Players.FirstOrDefault(i => i.Id == id); if (fromList == null){ GameManager.Players.Add(playerInfo); }
@g4mrplays
@g4mrplays 10 ай бұрын
How do you properly close a server? If say I wanted to restart it. Because CloseConnection() doesn't exist for c# it seems, closing godot is the only time i can close the server and restart a new host it seems?
@purplepixeleater
@purplepixeleater Ай бұрын
I believe you just set multiplayer peer = null
@obinnaokafor6252
@obinnaokafor6252 Жыл бұрын
Amazing
@tramos183
@tramos183 Жыл бұрын
I'm trying to test if I can connect to my local host and I keep getting CONNECTION FAILED when I press join game. I made sure the code, address, and port is correct but no luck.
@FinePointCGI
@FinePointCGI Жыл бұрын
Try running Godot in command line mode and see if any additional error show up. If you downloaded it from the website just go in and click on the bat file that gets downloaded with it and it should show the command prompt. From there you should be able to debug
@tramos183
@tramos183 Жыл бұрын
@@FinePointCGI ​It was my mistake, I was pressing host then join on the same instance. I needed to go to the other instance and press join. I never did anything with multiplayer so I thought the host had to join the server once it was created. Thank you for your help.
@meezi2987
@meezi2987 Жыл бұрын
Hello
@FinePointCGI
@FinePointCGI Жыл бұрын
Hello
@alexale5488
@alexale5488 4 ай бұрын
This tutorial is deprecated. It's Godot 4.2.2 and they already removed and rewrote stuff. Smh, I barely find this engine stable at all with all these changes. The engine is already left behind with quality documentation in comparison to Unity/Unreal. And now they break backwards compatibility in anyway. And their decisions to change the API's surface make no sense. For example, before you had method "create_server(adress, port)". Now you can only pass port as parameter as the server automatically picks some ip from the spectrum "0.0.0.0". If you want to bind an IP yourself you have to call a setter on the peer object "set_bind_ip(adress)". What is the purpose of this? Before was good enough, in fact better, as this is how every socket in initialized in every programming language. Godot's concept is great, but the direction the engine is taking starts to decline. They rush buggy features, they change things that could very well stay the same. When you improve a car, you modify the engine's internals, you don't switch the steering wheel from left to right side too. Great tutorial anyway. Sad that I am not finding my place in this engine anymore. I better write my own stuff, much easier to deal with than fighting ages with outdated tutorials and trying to grasp illogical syntax.
@FinePointCGI
@FinePointCGI 4 ай бұрын
Thank you for the complement on the tutorial! Godot does have a major problem with depecateing code at a whim. Its become very painful to create tutorials because they go out of date so fast. In this case when you do create server it picks the ip of the machine your on by default in the tutorial i use server = ENetMultiplayerPeer.new() var error = server.create_server(port, 2) if error != OK: print("cannot host: " + error) return server.get_host().compress(ENetConnection.COMPRESS_RANGE_CODER) multiplayer.set_multiplayer_peer(server) print("Waiting For Players!") and in 4.2.2 it works it binds to the ip and nothing was outdated that I can see. "create_server(adress, port)" was done in 3.2 and removed in 4.0.
@alexale5488
@alexale5488 4 ай бұрын
@@FinePointCGI Thank you too for feedback on my comment !
@robertbalassan
@robertbalassan 11 ай бұрын
i get something like this: E 0:00:16:0684 on_sync_receive: Ignoring sync data from non-authority or for missing node. Condition "true" is true. Continuing. modules/multiplayer/scene_replication_interface.cpp:873 @ on_sync_receive() but the problem is this way you setup things is client authority, multiplayer games are usually done by server authority, to prevent some forms of cheating. is there a way to setup server authority in godot? there must be a way
@FinePointCGI
@FinePointCGI 11 ай бұрын
I'll be looking at a dedicated server tutorial soon. It's on the list along with user management and saving
Creating a LAN Multiplayer Server Browser in Godot 4!
57:57
FinePointCGI
Рет қаралды 15 М.
Basics Of Multiplayer In Godot 4!
1:16:33
FinePointCGI
Рет қаралды 103 М.
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,8 МЛН
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 29 МЛН
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 620 М.
Why I haven't switched to Godot (Yet)
38:51
RobProductionsGames
Рет қаралды 6 М.
How I Would Start Game Development (If I Started Over)
16:59
Thomas Brush
Рет қаралды 122 М.
Creating a 3D Character Controller With Animations with Godot 4!
46:25
Add Multiplayer to your Godot Game!
58:51
Battery Acid Dev
Рет қаралды 54 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 388 М.
So you want to make a Game Engine!? (WATCH THIS before you start)
14:39
Giant Sloth Games
Рет қаралды 312 М.
I Tried Making A Game In Godot With C#.
6:51
Code It All
Рет қаралды 6 М.
How Games Make VFX (Demonstrated in Godot 4)
5:46
PlayWithFurcifer
Рет қаралды 350 М.