CardConquest Unity Multiplayer GameDev Blog #28: Using Steamworks + Mirror for Multiplayer Lobbies!

After I got CardConquest to a “playable” state with most of the gameplay features I wanted added (if not really “refined”), I wanted to add something to make multiplayer easier. Before, in order to play CardConquest, the easiest way to be on the same local network as your opponent. If you wanted to player over the Internet, the host of the game would need to do port forwarding on their router to allow for Mirror’s network communication.

Requiring players to do port forwarding to play means no one would ever play the game. So, I looked into Steamworks.NET to allow for players to host games locally and still play on the internet without requiring players to know how to configure their router. Steamworks allows for integration into Steam’s API, and one of the things that allows for is for lobby creation for locally hosted games.

To use Steamworks.NET in Unity with mirror, the FizzySteamworks package was used. I wrote a post about creating a barebones project on how to get Mirror+Steamworks up and running in Unity to create multiplayer lobbies. You can find the code for that project on Github. After creating that test project, I then adapted it to work with my CardConquest game.

How to Play the Game

Download the latest release from my Github Releases page. This will download a .zip file to your system. Extract the .zip file. In the extracted directory, double click on CardConquest-unity.exe to launch the game. Steam must be running on your system to play this version of CardConquest. If Steam isn’t running, the game won’t be able to create or search for lobbies.

You can also “Add” the game to Steam by clicking on “ADD A GAME” in the bottom left corner of steam and then clicking on “Add a Non-Steam Game…” Browse to where you extracted CardConquest-unity.exe and select it to add to steam.

When you launch the game, Steam will show you as playing “Spacewar.” This is because I am using the test “AppId” that Valve created for Spacewar. It looks like that AppId is used by game testers and uh, game pirates I think.

Starting A Game

The main menu of the game has been changed for Steamworks. You can choose to Create a Lobby or get a list of lobbies to find a game to join.

Click on Create Lobby to create a new game. You will be presented a few options for the new lobby.

The first option is what you want to name the lobby. If you enter nothing, it will be your Steam profile name + “‘s lobby.”

The friends only checkbox will make the game “private.” Only players who are invited to a game can join a private game. This is off by default.

Click on “Create Lobby” and the lobby will be created

Joining a Game

In the main menu, click on “Find Lobbies” to search for a game to join. This will show you a list of all lobbies.

The lobby search will only show “Spacewar” games that are tagged as “CardConquest,” so you are unlikely to see anything unless you know of someone already hosting a game. You can search for lobbies to filter based on the lobby name.

To join the lobby, click on Join Lobby.

After you are in a lobby, you can select your commander and ready up. After both players are ready, the game can start.

And then you play as normal!

Next Steps…

Not sure what to really add next to the game. I definitely need to figure out balancing the commanders/cards in some way. The other thing is maybe add some maps for players to choose from when creating a lobby?

Adding support for more than 2 players would be nice, and also a really big change to how the game fundamentally works. What happens when 3 people move to the same tile? Who fights who? Could you choose sides? Maybe I can figure that all out someday.

Smell ya later nerds!