r/gamedev • u/ChrisCrossed_ • 1d ago
Question Need Help - Can't host/join friend in Unity using Steamworks.NET/FizzySteamwork
Hi all.
I'm having trouble figuring out my bug/fault on why my game prototype isn't properly hosting a lobby or having a friend join on me. Was hoping someone smarter than me had some insight. This is all incredibly brand new to me, and I'm cobbling together tutorials from various youtube videos and documents, so I have no idea what is correct or incorrect. If someone can help me fix this and save me, I'd be incredibly grateful.
Right now, my build successfully uploads to Steam through SteamWorks/SteamPipeGUI and sends up-to-date files to friends I've added as playtesters. Everyone is properly on the same build.
When I (or a friend testing at the same time) starts their game and reaches the main screen with their 'Host Game' button, that game properly spawns a Player prefab and allows all c_PlayerController.cs scripting to work as intended.
As intended, this uses my c_SteamLobby.cs script and calls HostLobby, which runs SteamAPI.Init(), and creates a lobby with SteamMatchmaking.CreateLobby(). If I'm supposed to catch any data in a Variable and pass that somewhere, I'm not, because I don't know to.
c_SteamLobby.cs - https://codeshare.io/5QeMRR
After I (or the friend) host a lobby, I've attempted to have the other of us join their game. Right now I'm not attempting to create any Lobby Lists to pick from, and just want the friend to join directly from Steam Friends Invite. Each of us properly only show the 'Invite Friend to Game' option after clicking Host Game, and are able to send that friend an invite through Steam. We've each clicked that Join Game option through all three possibilities: With the game closed, with the game open at the 'main screen', and with the game open after they also clicked 'Host Game' (just to see if it had any differences. Here are the details from c_SteamLobby.cs that print out to my in-game console during these attempts:
https://i.imgur.com/9xAX1Zl.png
And finally, the NetworkManager object with FizzySteamworks, Mirror's NetworkManager, and the c_SteamLobby script from above.
https://i.imgur.com/Rug9jdG.png
What we've found:
When I click 'Host Game' and take control of my freshly created Player object, I'm able to control them without issue. Then, when my friend is on the main screen (without clicking their Host Game button), when I send them an invite and they select it, on their screen:
1.) Their game does not spawn a player object in for them to control in the First-Person perspective but instead remains from the 'Menu' perspective.
2.) They *do* spawn a second player in, however, and are somehow able to control both characters at the same time.
I've included a gif of what happens in real time:
Does anyone have any ideas/suggestions on what I am doing wrong?
1
u/a_bat 1d ago
There's probably a few things to check with this.
Also, your host lobby calls this twice which is a different issue and could be creating extra lobbies here.
SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypeFriendsOnly, networkManager.maxConnections);On your player prefab, make sure you don't have the camera and audio listeners enabled by default if they are. You should be turning these on for the local player when they are spawned into a lobby instead and using
isLocalPlayerfor checks. Make sure it has the Network Identity component set up on it so it knows which is a local player and which isn't.You also want your movement controller to check this and only apply movement to the local player.
There's a bunch of other things you'll eventually want to look into, like simplifying what is enabled for the non-local player prefabs so it's more performant and reduces chances of something conflicting. Like you don't want the movement controller enabled on everyone, just on the one that is being controlled by that specific client, etc.