📪Adding New Tracks

Guide

Tracks are defined by their TrackManager component. Every track must have its own TrackManager component to represent its layout.

Adding A New Track In A New Scene:

  • By default, the Complete Time Trial System package is setup to work with one track per Unity scene as it uses automatic assignment of references to prevent needing to manually assign components.

    • This is done using FindObjectOfType<TrackManager>() in Awake of LapTimeTrackingObject so fails with more than one TrackManager in the scene.

  • This has the benefit of being easy to use at the downside of flexibility. Should you prefer having multiple tracks per scene or a more flexible solution see the Adding New Tracks To The Same Scene section below to see how to handle reference assignment manually instead.

  • For adding time trials to a new track in a new scene, simply add a TrackManager component in that scene, and create the layout of your track as normal.

in LapTimeTrackingObject.cs:

private TrackManager currentTrackManager; // Declaration

currentTrackManager = FindObjectOfType<TrackManager>(); // Assignment in Awake()

Adding New Tracks To The Same Scene:

  • To add multiple tracks in the same scene, simply modify the TrackManager reference in LapTimeTrackingObject to not use FindObjectOfType but instead your own method of choice for assignment.

  • This can either be done manually by assigning the references in inspector or through a script that updates the TrackManager reference as you change track in game.

  • This can also be used to provide much more flexibility for time trials in your projects and allows you to update the TrackManager reference for individual LapTimeTrackingObjects at any point during gameplay.

  • For example, you could have 2 races going on simultaneously in the same Unity scene each making use of time trials for their own LapTimeTrackingObjects on each track.

What Next?

Last updated