Repository navigation
World
Bartholomew Ho edited this page Nov 9, 2026
·
1 revision
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.
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| 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. |
| 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. |
- Like every
Vehicle, the cars you get here are only valid for this frame. Don't keep them between ticks. - If you leave out
fromand you're not driving (noPlayer.Car),GetNearestVehiclereturns null andGetVehiclesInRangereturns an empty list. -
TimeOfDayandTimeScalethrow anInvalidOperationExceptionwhen the world isn't loaded. -
Waypointthrows anInvalidOperationExceptionwhen 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,
Waypointis always null andplatform.logsays 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
InvalidOperationExceptionthat says to useGame.TickorGame.Run.
Playing
Getting started
Writing mods
The FH2 classes
- Game
- Player
- Vehicle
- World
- Garage, CarCatalog, Profile
- UI and Hud
- Camera
- Audio
- ANNA
- Skills
- DebugOverlay
- Controller
- GameInput
- GameWindow
- Menus and UiElement
- SettingsTile
- ButtonIcons and Picture
- MapView, PhotoCamera, GarageCamera
More