Skip to content

Track Marker System

This track marker system allows you to create racing tracks in the Unity editor by clicking to add, edit, and delete waypoints.

How to Use

Creating a Track

  1. Create a TrackMarker ScriptableObject:
  2. Right-click in Project window
  3. Select Create → Race Timing → Track Markers
  4. Name it (e.g., "MyTrackMarkers")

  5. Add TrackMarkerManagerBehaviour to a GameObject:

  6. Create an empty GameObject in your scene
  7. Add the TrackMarkerManagerBehaviour component
  8. Assign your Track Markers asset to the component

  9. Edit the Track in Scene View:

  10. Select the GameObject with TrackMarkerManagerBehaviour
  11. In the Scene view:
    • Shift + Click on terrain/ground to add a new waypoint
    • Click on an existing waypoint to select it (you can then move it with the position handle)
    • Alt + Click near a waypoint to delete it
    • Delete Key to remove the selected waypoint

Keyboard Controls

  • Shift + Click: Add a new track marker at the clicked position
  • Alt + Click: Remove the nearest track marker
  • Click: Select a track marker for editing
  • Delete: Remove the currently selected track marker

Visual Feedback

  • Blue spheres show waypoint positions
  • Light blue lines connect waypoints in sequence
  • A line connects the last waypoint back to the first (forming a loop)
  • Labels show "Marker 1", "Marker 2", etc.

API Reference

TrackMarkerManagerBehaviour Methods

// Get the index of the nearest waypoint to a position
int GetNearestNodeIndex(Vector3 point)

// Get the position of a waypoint by index
Vector3 NodeFromIndex(int index)

// Add a marker at the end
void AddMarker(Vector3 newPoint)

// Add a marker at a specific index
void AddMarker(int index, Vector3 newPoint)

// Remove a marker by index
void RemoveMarker(int index)

// Move an existing marker
void MoveMarker(int index, Vector3 newTargetPosition)

// Get calculated track properties
List<Vector3> trackMarkers { get; }
List<float> cumulativeDistances { get; }
float totalTrackLength { get; }