Skip to content
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

Add a Network node #690

Closed
Shadowblitz16 opened this issue Apr 10, 2020 · 13 comments
Closed

Add a Network node #690

Shadowblitz16 opened this issue Apr 10, 2020 · 13 comments

Comments

@Shadowblitz16
Copy link

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..

  • a connection type (tcp, udp, rudp)
  • a connection key type (ip/port, keyword)
  • a connection password (or none)
  • a bool weather or not connections persist on scene change
  • a bool whether or not a new host will be found one the old host leaves
  • a bool whether or not a node is destroyed once it leaves

it would have the following signals..

  • host left
  • host joined
  • peer left
  • peer joined

it would have the following methods..

  • join(node:Node, key:string, pass:string)
  • leave(node:Node)
  • is_server()->bool checks if is server
  • is_client()->bool checks if is client (clients can be servers)
  • is_action_pressed(string:String)->bool client pressing inputs
  • is_action_just_pressed(string:String)->bool client pressed inputs
  • is_action_just_released(string:String)->bool client released inputs

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
Copy link
Member

mhilbrunner commented Apr 10, 2020

Related proposal: #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 godotengine/godot#16793

@Jummit
Copy link

Jummit commented Apr 10, 2020

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:

  • a connection type (tcp, udp, rudp) : high-level / low-level networking APIs, PacketPeerUDP, StreamPeerTCP

  • host left : SceneTree.server_disconnected

  • host joined : SceneTree.connected_to_server

  • peer left : SceneTree.network_peer_disconnected

  • join : SceneTree.connected_to_server

  • leave : SceneTree.network_peer_disconnected

  • is_server : SceneTree.is_network_server

  • is_client : not SceneTree.is_network_server

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

Useful Methods

  • a connection key type (ip/port, keyword)
  • a connection password (or none)
  • a bool whether or not a new host will be found one the old host leaves

Can be easily coded manually for more flexibility

  • a bool weather or not connections persist on scene change
  • a bool whether or not a node is destroyed once it leaves
  • is_action_pressed

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
Copy link
Author

Shadowblitz16 commented Apr 11, 2020

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

This comment has been minimized.

@Shadowblitz16
Copy link
Author

I edited my message

@aaronfranke
Copy link
Member

@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.

@Calinou Calinou changed the title Networking node? Add a Network node Apr 14, 2020
@Shadowblitz16
Copy link
Author

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
Copy link

huhund commented May 1, 2020

This sounds like a good idea for an add on.

@Shadowblitz16
Copy link
Author

Shadowblitz16 commented May 2, 2020

@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
Copy link

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
Copy link
Author

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

@Shadowblitz16
Copy link
Author

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

@ultrasuperpingu
Copy link

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:

  • A non-network application
  • A network application but not connected to any server yet
  • A network application connected to a server

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 ?

@aaronfranke aaronfranke closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants