Selecting game modes

Hello everyone,

I’m having a bit trouble getting around the concept of game modes. What I’m done so far is create a script, which is scriptable. Then I created a asset menu for it, then created 2 of them. One called solo, and the other called duo’s. Then I set the variables for both, like name, max players, and team sizes. In my RoomManager script, I created these two variables

    [SerializeField] private GameMode selectedGameMode;
    [SerializeField] private GameMode[] availableGameModes;

And a stringprivate const string GAME_MODE = "GameMode";
Now I’m unsure how to implement this, that when the player clicks play, it joins a room of that mode. Also the thing is the game mode is chosen before the player clicks play, so it has to read what is the current selected mode. Will appreciate all help, Thanks :E[

bump, its gone back A LOT:hushed:

I’ve not done this sort of stuff before, but I can imagine how it works based on what I know about other games.

Depends on the game, but the levels of games with different modes I’ve noticed work in two ways:

  • The levels/arenas are set up to support every possible game mode
  • Or the needed assets for the game mode are loaded on top of the level.

Halo is an example of the latter, what with Forge mode. The levels are more or less just geometry, then further geometry, spawn points and other objects are loaded in on top.

You’re going to need a way to define the behaviour of each particular mode, and do so in such a way that it works more or less modularly with the core gameplay. I can think of a few ways you could do this:

  • Have a ‘GameMode’ scene for each different game mode. This is then additively loaded with the level scene, players, etc.
  • Or define the game mode’s logic in an asset like a scriptable object.

I would personally do the former as it’d make breaking down the various aspects of the game mode into separate and reusable components a lot easier.

Then from there, you just set up buttons/UI/whatever to handle the loading.

I was pretty broad here; again, never done this before. I imagine this is the kind of think you’re just going to have to fuck around with in small island projects to see what works.

1 Like

I’ve done this, but instead of game logic, I defined the room’s properties, rules etc. Like max players, teams, and how big they are
In my menu, I have a button, which loads up a panel, which lets you choose your game mode (It basically shows 2 button, solo or duo) prior to clicking “Play” And joining a room. What I know to do is to make a method, which selects the game mode, and assign it for the on button click for each game mode button in the panel. I would appreciate any advice, on how to do this (Maybe some worded logic on how to do it)
Thanks!! :smile:

Are the gamemodes the same gameplay but with different variables?

Simplest is just to do it like this:

public class Example : MonoBehaviour
{
    public GameMode selected;
    public GameMode solo;
    public GameMode duo;

    public void OnButton1Clicked()
    {
        selected = solo;
    }

    public void OnButton2Clicked()
    {
        selected = duo;
    }

    public void OnButtonPlayClicked()
    {
        // Load level

        // Spawn players
        for (int i = 0; i < selected.MaxPlayers; i++)
        {
            // Instantiate prefabs
        }
    }
}
1 Like

Hey Stardog, Thanks for your reply!!

Well, not really. For instance, lets say I select the ‘Solo’ game mode, so then when I click play and go into matchmaking, it’ll find people doing the same gamemode, and when a room is created. It sets the properties, like team size, in this case it would be 0, so none. Because it’s solo, and max players in that room. If I select the ‘Duo’ game mode and click play. it’ll find people doing the same mode, and then I’ll make a teams feature, and set the properties of ‘team size’ max players in the room, etc
I reckon that’s a great example to get me started off with. I’ll try to make it fit my needs, etc and let you know how it goes.

Also, one other question, not related to this but in my lobby scene, I have a display model, of the character, tho when I build it, the character is not displayed. Not sure why, but any clue why?