The BaseObjManager interprets and manipulates an object based on its stats, which are controlled by the BaseStatsManager. It is also in charge of communicating with the GameManager and letting it know when something significant happens to the object it is attached to. Here’s a high-level example of how a character might work:

  • A projectile collides with the character. The character’s controller parses this collision and then invokes a function in BaseStatsManager to modify the character’s health (take damage).
  • BaseStatsManager subtracts the health accordingly, but then realizes the character’s health is now zero. It calls a function in BaseObjManager to handle character death.
  • BaseObjManager sends a message to the GameManager that this character is now dead and then calls an internal function that destroys the character.
  • The GameManager subtracts one life from the player’s total ‘lives’ pool and then spawns a new character for the player, which has a character controller, BaseStatsManager, and BaseObjManager attached.


using UnityEngine;
using System.Collections;

public class BaseObjManager : MonoBehaviour {
    public bool didInit;

    public BaseStatsManager DataManager;
    // note that we initialize on Awake in this class so that it is ready for other classes to
    // access our details when they initialize on Start.
    public virtual void Awake () {
        // rather than clutter up the start() func, we call Init to do any
        // startup specifics
    public virtual void Init () {
        // cache ref to our stats manager 
        DataManager= gameObject.GetComponent<BaseStatsManager>();

        // throw error if object is missing a BaseStatsManager
        if(DataManager == null)
            Debug.LogError ("GameObject is missing a BaseStatsManager: " +;
        // do play init things in this function
        didInit= true;


The script is designed with the theory that it will be reused, so it includes a didInit boolean for easier debugging of initialization commands. We then check if there is a BaseStatsManager attached, and throw an error if there is not.

Up Next: Input

The input controller abstracts input so that a game may compensate for different control schemes. This is useful for porting a game to another device such as mobile. The BaseInputController is intended to be extended, with each extension loaded as needed depending on the target platform or device. Read about it here: