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

steamworks p2p #49

Closed
ghost opened this issue Dec 24, 2018 · 31 comments
Closed

steamworks p2p #49

ghost opened this issue Dec 24, 2018 · 31 comments
Labels
enhancement Related to things needed in GodotSteam

Comments

@ghost
Copy link

ghost commented Dec 24, 2018

Hey, if im correct the whole steam networking part is not yet supported.
Are there any plans to implement it in the near future?
I realy like godot but i also need the p2p networking from steam and i dont think there is any other way of achieving this in a reasonable easy way, without switching the game engine (Unity, Unreal)

@Gramps
Copy link
Member

Gramps commented Dec 25, 2018

You are correct, it is not yet added in.

I do plan to add it along with the server stuff. Unless a contributor gets to it first.

What were you trying to achieve?

@ghost
Copy link
Author

ghost commented Dec 25, 2018

Well i want to establish a connection between two clients, so that they can play together.
Its a simple coop game, thats why i dont want to develop and host a server.

@Gramps
Copy link
Member

Gramps commented Dec 25, 2018

You should be able to do that with Godot's high level networking relatively easily. From what I've seen of Steam networking stuff, it's a bit more involved for simple things.

The major difference in my experience is that with Godot's, and no central server, needs port forwarding. I believe Steam's has NAT punching to avoid that.

That being said, I hope to have the server stuff and networking added sometime in January.

@Gramps
Copy link
Member

Gramps commented Dec 25, 2018

I also plan on doing a few tutorials for GodotSteam, including everything I've figure out on networking.

@ghost
Copy link

ghost commented Dec 25, 2018

@Gramps Looking forward to it. Appreciate your work on this. It's down the road for me, but definitely interested in the coming year being able to make some simple P2P games through Steam.

@Gramps
Copy link
Member

Gramps commented Dec 26, 2018

Cheers, sir! Yeah, hopefully by the time you're ready for P2P games I'll have everything added and tested, as well as some tutorials. Unfortunately there are so many hours in a day!

@ghost
Copy link

ghost commented Dec 26, 2018

Unfortunately there are so many hours in a day!

I certainly hear you on that. X)

@Fischer96
Copy link

Any news for P2P networking with steam?

@Gramps
Copy link
Member

Gramps commented Feb 27, 2019

Yep, P2P and Utilities are the next two major updates I'm working on! I should have it out sometime in March; hopefully sooner than later.

@Fischer96
Copy link

Nice!

Do you know if it's possible to create a Godot Steam Lobby currently and combine this with the High Level Networking Api to prevent NAT problems and so on?

@ghost
Copy link

ghost commented Feb 27, 2019

Yeah, was wondering that as well. Would be strange if you could lobby together, and the game fails to launch, and maybe inform the user that they have to setup port forwarding on their router to continue. XD

@Gramps
Copy link
Member

Gramps commented Feb 27, 2019

@Fischer96 @avencherus Sort of. My last game has a multiplayer component but requires users to port-forward currently. The Steam P2P stuff will get around that, as will Godot 3.1; provided their routers have UPnP (I believe). My game also has a not when hosting that you'll probably need to open the given port. But currently NAT is an issue.

I know there is a way to have each client and host connect to a central server then get paired together and remove the central server, but I have no idea how that works. Also Valve is going to start letting games use their servers which will clear up more problems.

What I've been doing is a marriage of the high-level networking and Steam stuff, until the Steam P2P stuff is done or 3.1 comes out. I have a host set up a 'lobby":

# Sending server data to the master server via http client to populate server list
func _sending_Server_Data(message):
	# Send data to master server
	var RESPONSE = http._add_Server_List(ip, port, name, players)
	call_deferred("_server_Set_Up")
	return RESPONSE

# The server is ready to go
func _server_Set_Up():
	# Set up the host game
	var RESPONSE = THREAD.wait_to_finish()
	# Activate the server locally
	var HOST = NetworkedMultiplayerENet.new()
	# Don't let more than one other player to join
	HOST.create_server(int(global.DEFAULT_PORT), 2)
	get_tree().set_network_peer(HOST)
	# Allow network connections
	get_tree().set_refuse_new_network_connections(false)
	# Set up the Steam information and lobby
	Steam.createLobby(2, 2)
	# Set player's network ID
	player1.NETWORK_ID = 1

The server is now accessible through my master server list (have a different node that pulls and displays this for users, and the "lobby" is created in Steam for people to join through the Steam GUI.

Some Steam functionality for handling invites and joins:

# Hosting a lobby callback from Steam with ID and connect string
func _host_Lobby(connect, lobbyID):
	print("Steam lobby is up! Connect response: "+str(connect)+" / Lobby ID: "+str(lobbyID))
	STEAM_LOBBY_ID = lobbyID

# Join request received from Steam callback
func _join_Request_Received(from_id, connect_string):
	print("Join request from: "+str(from_id)+" at connection: "+str(connect_string))
	# Strip the command line part out
	var NEW_HOST = connect_string.split("-host=", false)
	# Set invite IP as host
	global.HOST_IP = NEW_HOST[0]
	var FRIEND_NAME = Steam.getFriendPersonaName(from_id)
	_join_Game()

# Invite received from Steam callback
func _lobby_Invite_Received(inviterID, lobbyID, gameID):
	print("Invite received from: "+str(inviterID)+" from lobby: "+str(lobbyID)+" for game: "+str(gameID))
        # Mostly for debug purposes, can attach a function to do something here

That's just some bits and pieces of the whole thing. I will definitely do a longer tutorial with full examples soon. Maybe after 3.1 sees stable release so I can cut out some unnecessary stuff.

@Gramps
Copy link
Member

Gramps commented Mar 28, 2019

Hey all, wanted to update you guys that @Antokolos got P2P working in the GDNative branch and I have moved it into my 3.1 copy with no issues. Going to push that to the repo this weekend and then back-port to 3.0.6 and 2.1.5.

@ghost
Copy link

ghost commented Mar 28, 2019

Nice, looking forward to trying it out in the near future.

@Antokolos @Gramps 👍 🎉

@Gramps
Copy link
Member

Gramps commented Apr 6, 2019

OK, P2P / Networking functionality has been back-ported to Godot 3.x and Godot 2.x! I'll try to get a tutorial put together this month to help folks integrate it.... after I figure it out myself.

@Gramps Gramps closed this as completed Apr 6, 2019
@Gramps Gramps added the enhancement Related to things needed in GodotSteam label May 2, 2019
@drarem
Copy link

drarem commented Aug 30, 2019

is there a tutorial out for this yet, if so where?

*** OK, P2P / Networking functionality has been back-ported to Godot 3.x and Godot 2.x! I'll try to get a tutorial put together this month to help folks integrate it.... after I figure it out myself. ***

@Gramps
Copy link
Member

Gramps commented Aug 30, 2019

@drarem It's funny you should ask because I am actually working on it this weekend. I know this topic has been around for a bit but it's been an extremely busy summer over here. That being said, I am working on multiplayer for my current project and was going to tie the tutorial in with that.

I hope to have it up by Monday!

@drarem
Copy link

drarem commented Aug 30, 2019

Awesome, which game is this?

@Gramps
Copy link
Member

Gramps commented Aug 30, 2019

A game called Haulin' Oats, a digital board game about truck driving and oatmeal. I'm hoping to finally get the alpha playable in September!

@drarem
Copy link

drarem commented Aug 30, 2019

Preview looks good, love the art style.

@Gramps
Copy link
Member

Gramps commented Aug 30, 2019

Cheers! It's been a lot of tinkering up until now and still a ton more to do. I'll report back when that tutorial goes up.

@drarem
Copy link

drarem commented Aug 31, 2019

Did I see some comment about itchio, and if so a way to support your project or efforts?

@Gramps
Copy link
Member

Gramps commented Aug 31, 2019

Mmm, right now Haulin' Oats is only on Itch.io until I get another Steam app ID. GodotSteam does have a Patreon page.

@Ranoller
Copy link

Your patreon page is hidden to the world. Please promote that. I think that if i paste the link here (https://www.patreon.com/coaguco) there will be more visible that in the place I find it.... fix that!!!!
Maybe you can talk with remí about that.

@Gramps
Copy link
Member

Gramps commented Sep 1, 2019

Oh crap, is it not published or something? I think I linked it in the docs page. And thank you, sir!

@drarem
Copy link

drarem commented Sep 1, 2019

Thanks, just became a patreon :)

@Gramps
Copy link
Member

Gramps commented Sep 1, 2019

Thank you, sir! Added you guys to the contributor page in the docs.

I think tomorrow the first part of my tutorial will be ready. The P2P stuff is actually pretty simple, though it is missing some minor things from Godot's (like master/slave stuff).

@Gramps
Copy link
Member

Gramps commented Sep 2, 2019

Hey guys, wanted to keep you in the loop with the tutorial.

So I have a fully working lobby system in pure GodotSteam and GDScript. I can create, join, leave, etc. and am now testing the P2P aspects of passing data back and forth. Not sure I'll get it posted tonight; gotta sleep in about 3 hours. I still have to type it all up in the documentation after testing is done.

However, I should have it done tomorrow or the next day. When it is up, it'll be the full tutorial for lobby and P2P networking. I will also update the example repo with the full TSCN file and GD file so you can see the code and even test it out yourselves!

Will report back once my testing is done, the tutorial is up, and the example repo is updated!

@Gramps
Copy link
Member

Gramps commented Sep 3, 2019

OK, wanted to write one more update before I go to sleep. I just pushed an update to the Example branch that contains my code for the tutorial. It has all the stuff I mentioned in my last comment.

Tomorrow when I get home and settled, I'll start writing it all up for the tutorial then add that to the documentation and will report back again!

@Gramps
Copy link
Member

Gramps commented Sep 3, 2019

Alright fellas, the new lobby / P2P tutorial is up in the documentation page! It covers pretty much everything I mentioned above except invite systems. That will be added in the second half of the tutorial that should go up sometime this weekend.

I'd like to give a big shout-out to @Antokolos for leading me in the right direction on the P2P stuff.

If you guys notice anything weird or poorly explained, please let me know so I can get it fixed up! And part two is coming soon!

@Antokolos
Copy link

Glad to help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Related to things needed in GodotSteam
Projects
None yet
Development

No branches or pull requests

5 participants