-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Update high level multiplayer manual for Godot 4. #7675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
To create that object, it first has to be initialized as a server or client. | ||
Every node has a ``multiplayer`` property, which is a reference to a default ``MultiplayerAPI`` instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading, unless defined for the sub-tree it defaults to the default one, but this implies it's always a default one
get_tree().network_peer = peer | ||
# By default, these expressions are equivalent. | ||
multiplayer | ||
get_tree().get_multiplayer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, only if none has been configured, this is going to confuse people
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I put the "by default" for, but I can see it not being clear enough. I'm open to suggestions for better language since I'm not too sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this relevant? It's only true for a very specific case, so it's unhelpful information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to specifically mention that Node.multiplayer
is a reference to a "global" object, and not one unique per node. I've seen people ask why you cannot set this property even though you can get it. When learning the API I was myself confused about why one can just get multiplayer from every node and receive the same object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the correct code is get_tree().get_multiplayer(get_path())
Though this is already documented in Node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find get_tree().get_multiplayer()
to be overly verbose. get_multiplayer()
works on its own and makes more sense in my opinion. This is important for a tutorial.
Edit: Sorry, just read that multiplayer
also works. It's also a good solution. Makes sense with the rest of Godot syntax of offering direct access and get & setters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are not equivalent, as is the entire point of this discussion here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are not equivalent, as is the entire point of this discussion here
I'm not saying that they are. I'm saying I'm not fond of using get_tree().get_multiplayer()
for the reasons explained. If people really believe it's a must, I believe further explanation is necessary. Because otherwise, people will have the same doubts that we are having in this discussion.
Reasons to use get_tree().get_multiplayer()
should be clear if used in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry your original comment made it seem that way based on the suggestion of replacing one with the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, no worries. It was confusing, the way I put it. My fault as well.
Always please feel free to argue my posts. I'm new here, so I appreciate a lot the feedback. Hopefully I may contribute to the discussion.
@Jordyfel Thanks for working on this, I've work in progress on expanding and reworking the networking sections, but as that turned out to take longer than anticipated I had planned to do a quicker update of the existing ones - so this is very welcome. I'm currently building this page locally and will be reviewing it, thanks for contributing to Godot, especially to networking docs ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I've finally found time to review this in depth. This is a great update to bring this page up to date for Godot 4.
I've found a few things, but these may as well be worth doing in followup PRs (by you, me or someone else):
- The warning about the Android INTERNET permission was removed in this PR. Was that intentional?
- Where it explains the signals, the signal names should probably be links to their class docs.
- I think the flow of the page could be improved (that has nothing to do with this PR though, it was already the case before): It starts with a lot of very high level general networking talk, then gets nitty gritty, and kinda goes back and forth and thats hard to follow. We should probably split the general networking overview, security considerations, comparing Godot's networking technologies etc. from the actual "this is how you use MultiplayerAPI".
It also needs advanced tutorials for the synchronizer tech etc, but that too is out of scope for this PR, just adding context.
All in all, I'll likely merge this sooner rather than later and iterate based on it, as I have further changes in my own fork and will work on the above (further PRs are of course welcome!)
Because as of right now, the current state of the page is badly outdated, so I'm in favor of improving it and then improving it further, rather than spending more time before merging. :)
I agree with everything you mentioned, this page probably has to be split/reorganized, though I'm not very confident in doing that since my networking knowledge is rather surface level. I just wanted to have all the basics in one place sooner rather than later because this API, more than most other, is a pain to figure out from the class reference as a new user (not so much the case for the scene replication nodes, which is why I didn't include them, though it would be better if they had tutorials as well). I didn't notice the android permission warning, will put it back as it was. |
Agreed. I was myself in this situation. It's very painful to figure it out as a novice. |
Merged! Thanks and congrats @Jordyfel, this is amazing, doubly so for a first contribution :)
Absolutely. We strive to keep things as welcoming as reasonably possible, but we absolutely do not try to teach people game development (or network engineering), that is way out of scope of the docs and our resources. The Godot docs are meant to be a technical manual for this specific game engine; creating in-depth networking/multiplayer tutorials is work for the greater community, we can only hope to manage to document the tech. (And even with that we really need help, as this PR shows! :)) |
Other issues I found which can seemingly also be closed by this: #5754, #7142. @mhilbrunner Some guy on reddit complained that the issue he was tracking wasn't closed. |
Thanks for the ping, I closed those issues now :) |
Updates the high level multiplayer manual for Godot 4.
I have used the class reference, blog posts and my experience as a user of the API to get the information. I expect to have missed some details as I don't know the internals of
MultiplayerAPI
.