Members Area

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


The Spaceteam Admiral's Club is a community of friends and fans of the game [Spaceteam]. Anyone can create an account but there are special rewards if you support my future projects by becoming a paying member!

Join the Admiral's Club- Henry (aka Captain Spaceteam)

CaptainsMess first release

I've released the first version of my CaptainsMess networking library for Unity!
CaptainsMess on GitHub: https://github.com/hengineer/CaptainsMess

So far it only supports Wifi but I'm planning to add Bluetooth at some point.

Please use this thread for questions, suggestions, and general discussion about the library.

Comments

  • Once a game begins, I'm still able to mess with several buttons that shouldn't be available while a game is active (not ready, cancel, etc). Could you include an example of a simple game starting?

    The simplest game I could think of that would demonstrate a progressing game state is first to three of a random number provided by a button press of each user. (User presses button, number rolled displayed to everyone, once all button's pressed/numbers generated, they are compared, winner gets point or tie awards no points).

    On a different note, if two players are connected, and either cancels, the non-canceled players screen is either "..." for host and "Lobby" for clients. I think this message should be "Disconnected" or otherwise let the user know that they need to give action to continue trying to find a game.

    Thank you for making this open source. Networking has always been my biggest hurdle in game creation.
  • Sure, I will add something to the example project this week. For Spaceteam I'm currently using an Animator state machine for tracking game state but I'm still experimenting with it and for the example I wanted to keep things as simple as possible.
    Same with the "Lobby" text field: I wanted to provide a bare minimum example but it certainly has some issues.
  • Hi @Aki , I just pushed a new version of the CaptainsMess library with a simple dice-rolling game as you suggested. Hope it helps.
    The network and game states are handled a bit better, but they're not perfect yet. And I'm still figuring out how to prevent the NetworkManager from changing scenes as it's connecting.
  • Initial test/attempt-to-break-pass works well. It will be later in the week before I can take a crack at understanding the code. Thank you for being awesome!
  • Just spent the whole day messing with this for my latest project. I had been trying to make my own solution for a local networking game, but your system is already much better than I had. I definitely will continue to use it!
  • @hengineer
    Thank you so much for releasing this. Already hit the ground running with it and it's totally exceeding my expectations.

    One question:
    Is there any way to test a game with multiple players on one device? Separate builds don't seem to work like standard Unity networking. I'm running out of devices to test on.
  • Thanks ConnorB! I'm glad it's useful to someone.
    Unfortunately you can't have multiple players on one device at the moment. It could probably be added since Unity's lobby system does allow multiple players per connection, but I haven't looked into it.
    Feel free to experiment!

    For my own local testing I often run the game on my desktop computer and laptop, which is quicker and easier that testing on real devices.
  • @ConnorB

    For testing on a local device, there are some minor issues but I can get away with it fairly easily by tweaking CaptainsMessNetworkManager

    On line 159:
    bool isMe = (aServer.peerId == peerId);

    I simply add the line following:
    isMe = false;

    This isn't a long term nor great solution, and some issues are caused when trying to auto connect. But for "I want to get 5 instances on the same machine to join together for basic testing" situations, works fine for me.
  • @TobiahZarlez

    Thank you so much. I no longer have to have to use 3 laptops and my phone to test. You are a life saver
  • Ok...so I'm almost done with my game. Last few steps that I need some help on. How do you end the game and put the players back in the lobby together? Don't need exact code, just need a general idea. The example only has an option to play again. Any help would be greatly appreciated.
  • You can end a game at any time by using CaptainsMess.Cancel() but this will not keep the lobby open. If you want to keep the players connected and potentially start another game then there's a missing piece that I've added in Spaceteam but haven't back-ported to CaptainsMess yet. I'll do that today or tomorrow.
  • Ok, @ConnorB, I updated CaptainsMess library with a new "FinishGame" function. Call this when your game is over so it knows you are back in the lobby. As long as you don't call Cancel() then the players will still be connected and you can return to the lobby screen. You should now be able to start a new game with the same players.
  • Having said that, I now realize that the existing lobby might not accept any new players after the game has finished. So you would have to play with the same players or exit the lobby and start a new game.
    In the next version I'll make sure that the lobby is re-opened after the game is over.
  • Awesome. Thanks again. You don't know how helpful you've been.
  • Hi everybody!
    First of all i want to thanks for sharing this project.
    I'n not too good in network programming, so i want to ask for your help.
    I'm trying to make different GUI for host and client and when host press a button at client must changes something, for example to appear a text.
    Can you give me some advises ?
    Thx.
  • Hi @Homa,
    The example included with the CaptainsMess project has a simple game where each person presses a button and then the game does some calculations and changes some text. It's not great but it's a starting point.

    For the game you're describing I would send a ClientRpc message when the host presses their button and then the client can display the text when they receive it.

    You can learn how to use Unity's High-Level Networking API from the official documentation here: https://docs.unity3d.com/Manual/UNetUsingHLAPI.html
  • hengineer, thx for advice!
    But, honest, i was working a week with no resultant and yesterday i tried ClientRpc and it worked.
    Thanks one more time for this awesome project!
    Have a nice day.
  • Hi @hengineer
    Can you please tell me if i can use your project for 3D real-time game ? I'm trying to see another player, but with no results :(
    Thx.
  • CaptainsMess only handles the discovery of nearby devices and initial connection so once your players are connected then there are no restrictions on the type of game you can make. You can certainly make a 3D game if you want.
    I recommend following the Unity tutorials for setting up a networked game (without CaptainsMess). Once you have something basic working then you can add CaptainsMess later to make connections easier.
Sign In or Register to comment.