The Track - Group6OxCS/game GitHub Wiki
Track Controller
The track is kept track of by the Track Controller Object.
Currently, it has two notable features:
- A component script, Track Controller, which is the interface to information to do with the track
- A GameObject Markers which contains all of the track marker GameObjects in order (for organisational purposes, mainly).
Track Controller Script
The track controller contains an array of the individual marker GameObjects, exposing two ways of interacting with that array:
- LastVisited, the index in that array of the marker last visited by the car.
- GetNextMarkers(n), which returns an array of the positions of the n next markers the car has yet to visit along the track. (This method hasn't been tested yet)
LastVisited is maintained by detecting collisions between markers and the car's collision box. Each marker has a reference to the Track Controller, so when it detects the car has entered it, it updates the index accordingly.
Notes
- Currently, the markers need to be created and added manually. Additionally, all of the object references need to be performed manually in the editor (by dragging and dropping).
- Adding many track markers at once can be done by locking the inspector (using the lock icon at the top of the pane), then dragging them all at once onto the markers array field in TrackController (Script).
- The markers are currently rendered as transparent purple blobs. To not render them, one needs to change the alpha value of the TrackMarkerMat material to 0.