godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a Network node #690

Closed Shadowblitz16 closed 3 years ago

Shadowblitz16 commented 4 years ago

Describe the project you are working on: space ship game

Describe the problem or limitation you are having in your project: I would like to make a online multiplayer game but am finding that it takes an awful lot of code to set it up.

Describe the feature / enhancement and how it helps to overcome the problem or limitation: Make a Network Node basically it would be a node that syncs nodes over the network

it would have the following properties..

it would have the following signals..

it would have the following methods..

it would also have allow you to click properties in the inspector and sync them

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

extends Area2D
onready var net = get_node("NetworkNode")

func _process(delta):
    if net.is_pressed("ui_accept"):
            net.join(self, "myuniqueconnectionkey", "mypassword")
    if net.is_pressed("ui_cancel"):
            net.leave(self)

If this enhancement will not be used often, can it be worked around with a few lines of script?: it would be used alot by people that don't understand networking code. I wouldn't say it could be worked around with a few lines of script but it could be worked around. the issue is how many people want to dive into net code opposed to how many want to just have a node to manage it for them

Is there a reason why this should be core and not an add-on in the asset library?: I think it would be useful and how many game engines can say they have a built in networking entity for ease of use.

mhilbrunner commented 4 years ago

Related proposal: https://github.com/godotengine/godot-proposals/issues/75 (maybe this could be considered a duplicate of that, there is overlap, maybe we should see about merging the proposals)

Also relevant discussion in issue https://github.com/godotengine/godot/issues/16793

Jummit commented 4 years ago

I would like to make a online multiplayer game but am finding that it takes an awful lot of code to set it up.

I don't think there is a way around that problem that doesn't involve adding very high-level features to Godot, which isn't always a bad thing, but most of what you are proposing is better written in GDScript for more flexibility. I'd suggest you start of small and then try to make bigger games.

Having some experience with the high-level networking API, this feature seems useful at first, but wouldn't really make networking easier. Most of what this node could do is easily coded in GDScript, which then is a lot more flexible than a node.

Some of the methods/signals/bools exist already:

These are new features, some of which I actually like:

Useful Methods

Can be easily coded manually for more flexibility

While Godot has some nodes similar to this, for example the HTTPRequest node, I think packing all this functionality into a node is not the best way to do it. I'd suggest putting it in NetworkedMultiplayerENet or maybe SceneTree.

Shadowblitz16 commented 4 years ago

godot's whole system revolves around nodes. I remember making a simple suggestion for controls to have a offset in containers but it was shutdown due to there being a center container node.

now people are telling me we shouldn't have a node for networking?

I respect your opinion jummit but I strongly disagree. I think the there should be a node and script alternative to most things networking being one of them.

while scripts allow for more customization on how things work, nodes are easier to use and require less work and time to use.

I think that a networking node would make it a lot easier to make multiplayer games and godot would benefit from this since ease of use attracts new users.

Jummit commented 4 years ago

I think the there should be a node and script alternative to everything.

There shouldn't be a node and script alternative to everything.

Shadowblitz16 commented 4 years ago

I edited my message

aaronfranke commented 4 years ago

@Jummit kindly took the time to summarize the currently available networking features in Godot, which seems to cover the majority of the content in the proposal. The question now isn't a matter of "we shouldn't have a node for networking". In order for this proposal to be valid, someone should address @Jummit's post with a detailed explanation of why the current system is inadequate and give examples of how a new system would be an improvement, not just "I find the current system hard and one possible fix would have these features".

There is also the question of "Is there a reason why this should be core and not an add-on in the asset library?". It would likely be possible for someone to create some kind of Node-based abstraction for Godot's networking system in GDScript. This could be created as a proof-of-concept at the very least, and could maybe end up with an implementation inside of Godot, or otherwise it could be published to the Godot asset library and users could easily download it.

Shadowblitz16 commented 4 years ago

the problem with having it as a addon is it would have to be updated with the engine. I don't really see how people can justify having a http request node and not a networking node. I'm sure the http request node can be done through code too but its nicer to have a node that can do most of the work for you.

networking is a built in feature so it only makes sense there would be a node for it

huhund commented 4 years ago

This sounds like a good idea for an add on.

Shadowblitz16 commented 4 years ago

@huhund Well we could say that for anything that is suggested but it wouldn't make the godot engine better.

my main goal of this suggestion is to make networking easy to do at a large level.

instead of just saying it should be added as a addon tell me what you do think the engine should handle networking wise?

right now I don't think the networking in godot is that great.

here is a example how I think it could be better

extends Node

func _ready():
   var error get_root().connect(self, "127.0.0.1", 12345, NETSERVERANDCLIENT, NETRUDP)
   if error: print(error)

func _network_host_connected(connection_info):
   print("is host"+str(is_host()))
   print("is peer"+str(is_peer()))
   print(connection_info.ip+str(connection_info.port)+str(connection_info.node))
func _network_host_disconnected(connection_info):
   print("is host"+str(is_host()))
   print("is peer"+str(is_peer()))
   print(connection_info.ip+str(connection_info.port)+str(connection_info.node))
func _network_peer_connected(connection_info):
   print("is host"+str(is_host()))
   print("is peer"+str(is_peer()))
   print(connection_info.ip+str(connection_info.port)+str(connection_info.node))
func _network_peer_disconnected(connection_info):
   print("is host"+str(is_host()))
   print("is peer"+str(is_peer()))
   print(connection_info.ip+str(connection_info.port)+str(connection_info.node))

this would be done with code and would be alot easier to manage

jonbonazza commented 3 years ago

There is no way to sufficiently do this geberically that is optimized for ever use case in every game. @AndreaCatania is working on something but it's still going to require a good amount of setup and it's still only going to work for the 80%.

Multiplayer games are very hard on multiple levels. You aren't going to save much of that complexity with fancy nodes and such, as that's the easier parts of multiplayer games. In fact, a generic network node, while easier to setup than writing sometging game soecific from scratch, is actually not ideal in many ways for production use in most situationd. It's still useful for testing/prototyping, and also in sone very niche areas, but yea..

From a lot of your recent proposals, you seem to be looking for an easy way to make a multiplayer gane, which you simply arent going to find. If there were such a framework, it would have to be extremely opinionated and work for a very apecific type of game. Definitely not something that eould (or even should) ever be included in Godot core.

Shadowblitz16 commented 3 years ago

@jonbonazza Like what? if it doesn't cover a use case then that can be added in the future

Shadowblitz16 commented 3 years ago

I'm closing this for now. I will make a new suggestion if #1869 is accepted to reflect on that

ultrasuperpingu commented 7 months ago

I'm sorry to dig this old topic but it looks like it's the closest one to my problem.

I'm not saying the api should change, I'm just looking at it. But I'm tring to figure out how I can know if the process is a client. To know if it's a server, ok, SceneTree.is_network_server does the job. But I saw this statement in this post:

  • is_client : not SceneTree.is_network_server

and it can't be true. If you're not a network server, you can be either:

And worse, you can be both a server and a client (an host).

I know I can connect to the ConnectedToServer signal to be sure the CreateClient method was a success and provide this information on my own but it would be nice to be able to get the information without that.

I think it would be nice to have convenient methods to be able to know the current state of the connection. And I didn't find in the documentation a cristal clear way to get this information. Can anyone help me for this ?