Best practices on Multiplayer game modes

Hi

Im coding a Multiplayer game right now the game is split screen local multiplayer only but I would like to know the best practices to code different multiplayer game modes, like deathmatch, team deathmatch, etc… I have a Game Manager that has a function to end the match when its called but Im sensing if I try to hard code every single gamemode on the Game Manager the code will become a mess rather quickly so I would like to know the best aproaches to this subject…

If you made a multiplayer game with different game modes I love to see examples on how you implemented them…

Thanks in advance.

My recommendation (and this is just one of many different approaches) is to use composition. Don’t use a single Game Manager, and don’t make subclasses of Game Manager.

Instead, build each rule or subsystem as a separate component. This way, you can mix and match to create different game modes, and each script is short and easy to understand, with a single, clear purpose.

Thank you for the tip, end up doing something similar I still have the game manager but the conditions to win are in separate scripts so I use one class or another depending on the game mode. for example I did this for the deathmatch mode:

using UnityEngine;
using System.Collections;
public class DeathMatch : MonoBehaviour {
    GameManager _GameManager;

    // Use this for initialization
    void Start () {
        _GameManager = gameObject.GetComponent<GameManager>();
    }
   
    // Update is called once per frame
    public void CheckCondition(){
    for (int i = 0; i< _GameManager.PlayerChart.Count;i++){
    if (_GameManager.PlayerChart[i].PlayerFrags >= MatchInformation.Instance.MaxNumOfFrags){
        _GameManager.EndMatchFunc();
            }
   
   
        }
    }
}

So every time someone score a Frag the GameManager sends a message asking to check if the conditions to win are met if the condition is true then the EndMatch funtion is ran and the match is over.

Nice

Im trying to do the same thing for making gamemodes and this really helped thx

Please don’t necro posts like this. This post is over 7 years old. To show your appreciation, simply click the Like button.

Thanks.

1 Like