Skip to content
Bartholomew Ho edited this page Nov 9, 2026 · 1 revision

World

The world around you: every car on the road, the nearest ones, the time of day and how fast it passes, and the waypoint you've set on the map.

Thread: game thread only (Game.Tick, Game.Run, an ANNA entry). Waypoint can be read from any thread.

Example

Two ANNA menu entries: one tells you how far the nearest Drivatar is, one sets the time to noon.

protected override void OnInit()
{
    ANNA.Menu.Add("Nearest Drivatar", () =>
    {
        var mine = Player.Car;
        var other = World.GetNearestVehicle(kind: VehicleKind.Drivatar);
        if (mine is null || other is null) return;
        UI.Notify(other.Model?.ShortName ?? "A car", $"{mine.DistanceTo(other):F0} m away");
    });
    ANNA.Menu.Add("Noon", () => World.TimeOfDay = TimeSpan.FromHours(12));
}
Protected Overrides Sub OnInit()
    ANNA.Menu.Add("Nearest Drivatar",
        Sub()
            Dim mine = Player.Car
            Dim other = World.GetNearestVehicle(kind:=VehicleKind.Drivatar)
            If mine Is Nothing OrElse other Is Nothing Then Return
            UI.Notify(If(other.Model?.ShortName, "A car"), $"{mine.DistanceTo(other):F0} m away")
        End Sub)
    ANNA.Menu.Add("Noon", Sub() World.TimeOfDay = TimeSpan.FromHours(12))
End Sub

Members

Properties

Member What it does
Vehicles (property, get, IReadOnlyList<Vehicle>) Every car the game updated last frame: yours, Drivatars, traffic.
TimeOfDay (property, get/set, TimeSpan) The time of day, as the world's clock has it. Setting it moves the sun straight away. Values past 24 hours (or below 0) wrap round.
TimeScale (property, get/set, float) How fast the clock runs: 1 is the game's own pace, 0 stops it. Values below 0 are set as 0.
Waypoint (property, get, Vector3?) The waypoint you've set on the map, or null if there's none (or the HUD isn't up to say, in the garage for example). It's on the road where the sat-nav's route ends, with the ground's height; or the map's pin when there's no route. Any thread.

Methods

Member What it does
GetNearestVehicle(Vector3? from = null, VehicleKind? kind = null) → Vehicle? The car nearest from (your car's position if you leave it out), not counting yours. Only cars of kind, if you give one. Null if there's none.
GetVehiclesInRange(float radius, Vector3? from = null) → IReadOnlyList<Vehicle> Cars within radius metres of from (your car if you leave it out), nearest first, not counting yours.

Notes

  • Like every Vehicle, the cars you get here are only valid for this frame. Don't keep them between ticks.
  • If you leave out from and you're not driving (no Player.Car), GetNearestVehicle returns null and GetVehiclesInRange returns an empty list.
  • TimeOfDay and TimeScale throw an InvalidOperationException when the world isn't loaded.
  • Waypoint throws an InvalidOperationException when the game isn't ready yet (still loading, or a game build the SDK doesn't know).
  • On a game build where the sat-nav isn't as expected, Waypoint is always null and platform.log says so ("World.Waypoint off").
  • Distances and positions are in metres: X and Z across the map, Y up.
  • Using the game-thread members from another thread throws an InvalidOperationException that says to use Game.Tick or Game.Run.

See also

Clone this wiki locally