(not)Tron Development - Pickups

Since I dropped trying to get the lightcycle to behave. I've gone over to the other features that need addressing to even fulfil what I pitched by the end of the project cycle.



Firstly I went about creating the actual tokens for each pickup. They're pictured below and simply consist of an outer circle with the icon in the middle to tell the player what it does hopefully without them finding out after they used it.

These tokens are mainly placeholder but clean enough to stay in the game for a little bit til I think of a polished version of it.
The pickups are triggered when a player passes through it. Using Unity's EventSystem that I only just learned about on Wednesday, each pickup triggers an event like...

EventManager.Instance.OnTimeSlow.Invoke();  
//OnTimeSlow is the event name, which can be renamed to whatever
//Invoke takes no parameters because none has been setup
//If an event received a GameObject, then you would pass it like, .Invoke(gameObject);

The events are setup like below in a script called EventManager. They are called using the same method above.

public class TimeSlow : UnityEvent {  
    //Something goes here...
}

public TimeSlow OnTimeSlow = new TimeSlow();  

The EventManager will always exist in the scene no matter what, it's all thanks to the code below...

//Variables
private static EventManager inst;  
public static EventManager Instance {  
    get {
        if(inst == null) {
        var newthing = new GameObject("EventManager");
            inst = newthing.AddComponent<EventManager>();
        }

    return inst;
    }
}

void Awake() {  
    if(inst != null) {
        DestroyImmediate(this);
    return;
    }

    inst = this;
}

Then any listener's setup for that event receives the trigger and fires.

EventManager.Instance.OnTimeSlow.AddListener(() => {  
    Debug.Log("Slowing down time");

    //Start a timer, once complete, reset the timescale
    Time.timeScale = .5f;
    isTimeSlow = true;
    timeSlowEndTime = Time.time + timeSlowDuration;
    timeSlowTimer = Time.time;
});



Then with all these events setup for the pickup system. And each pickup firing it's own event, it allows for the below representation to work quite well.
So with pickups done, all that's left is networking, the menu system and getting the trail to behave kindly with a collider on it.

Tom Lynn

Read more posts by this author.

Australia http://rubbix.net