Flight Camera
beginner conceptsWorld Map Globe Ultra Edition · Core Concepts
The Planetary Flight Camera component flies the camera over the globe, from outer space down to the ground. Add it to the camera of the scene. The globe needs one flight camera, and the terrain loads for its view.
Inspector
Location Settings
| Setting | Default | Description |
|---|---|---|
Latitudelatitude | 40.78 | Latitude of the camera at the start, in degrees. |
Longitudelongitude | -3.97 | Longitude of the camera at the start, in degrees. |
Altitude (m)altitudeMetres | 800000 | Altitude of the camera at the start, in meters above sea level. |
At the start, the camera looks to the north and down. In Edit mode, the Game view shows this place, so you can choose the start of your application without entering Play mode. The panel of the Scene view sets the same values. See Scene View.
Navigation & Camera Control
| Setting | Default | Description |
|---|---|---|
Globeglobe | - | Globe that this camera flies over. The globe sets it when it is enabled. |
SpeedspeedFactor | 0.5 | Speed of the camera in relation to its height over the ground. With 0.5 it moves half of that height each second, so it is fast in orbit and slow near the ground. |
Fast Speed Multiplierboost | 8 | Speed multiplier while Shift is held. |
Look SensitivitylookRadiansPerPixel | 0.003 | Turn of the camera, in radians, for each pixel that the mouse moves. |
Ground Clearance (m)clearanceMetres | 1 | Smallest distance in meters that the camera keeps from the ground. |
Level HorizonlevelHorizon | On | Keeps the horizon level. The camera turns around the vertical of the planet and does not roll, and Q and E move the camera down and up. When it is off, Q and E roll the camera. |
Controls
| Input | Action |
|---|---|
| W / S | Move forward and back along the view. |
| A / D | Move left and right. |
| Q / E | With Level Horizon: move down and up along the vertical of the planet. Without it: roll the camera. |
| Space / Left Ctrl | Move toward the top and the bottom of the screen. |
| Right mouse button and mouse | Look around. |
| Shift | Fly faster, by the Fast Speed Multiplier. |
The left mouse button is free for your own use, for example to select countries with Planetary Interaction. The controls read the keyboard and the mouse. On a touch device, move the camera from your own scripts, for example with FlyToLocation. While the user writes in a text field of your interface, set ignoreKeys to true so that the keys do not move the camera. The mouse still turns it.
Waiting for the Terrain
With Wait For Terrain on (in the Navigation & Camera Control section of the globe), the camera does not go down into places whose detailed elevation has not arrived yet. Where nothing is known, it waits above Unknown Terrain Altitude (m), 12,000 meters by default. Horizontal flight and climbs are not limited. The StatusText property of the globe, and the Status line of its inspector in Play mode, say when the camera is waiting.
Flights
FlyToLocation flies the camera from where it is to a view of a place:
// Latitude, longitude, altitude in meters above sea level, duration in seconds
globe.flightCamera.FlyToLocation(45.8326, 6.8652, 6500);
globe.flightCamera.FlyToLocation(27.9881, 86.925, 10500, 12);
- The flight ends south of the place, at the given altitude above sea level, looking to the north at the place, which is in the center of the view.
- The camera stays above the terrain at the end of the flight.
- The route rises from its start and comes down over the destination.
- With a duration of 0, the default, the duration follows the distance.
- The terrain of the destination loads during the flight.
- The flight stops when the user moves the camera with the keys.
StopFlight()also stops it and leaves the camera where it is, andSetLocationstops it and moves the camera to another place.
The globe also flies to cities and to addresses. See Cities, Places & Anchors.
Public API
| Member | Description |
|---|---|
void FlyToLocation(double latitude, double longitude, double altitude, double seconds = 0) | Flies to a view of a place. See Flights. |
bool IsFlying | True during a flight. |
void StopFlight() | Ends the current flight and leaves the camera where it is. |
void SetLocation(double lat, double lon, double altitude) | Moves the camera at once to a place, at an altitude in meters above sea level, looking to the north and down. It also ends a flight. |
FlightPose Pose | Place and orientation of the camera: Position in meters from the center of the planet, Forward, Up, Right and Velocity. |
Camera View | The Unity camera. Use View.ScreenPointToRay to make rays for the queries of the globe. |
double SurfaceClearance | Height of the camera over the drawn ground, in meters. |
WorldMapGlobeUltra globe | Globe that the camera flies over. |
double latitude, longitude, altitudeMetres | Start place of the camera. |
float speedFactor, boost, lookRadiansPerPixel, clearanceMetres | Speed, Fast Speed Multiplier, Look Sensitivity and Ground Clearance. |
bool levelHorizon | Level Horizon option. |
bool ignoreKeys | Ignores the keys that move the camera, for example while the user writes in a text field. Off by default. It is set from scripts. |
FlightPose and the coordinate helpers are in the WPM.Planetary namespace. PlanetCoordinates.ToPlanet(latitude, longitude, height) gives the position of a place in meters from the center of the planet, and PlanetCoordinates.FromPlanet gives the latitude, the longitude and the height of a position. The planet is a sphere of 6,371 km of radius, and altitudes above sea level are measured from this sphere.
Preparing the Terrain in Advance
Code that knows where the camera will be soon, for example the path of a vehicle that the camera follows, can set AnticipatedView on the globe. The terrain of that view is prepared after the needs of the current view, so it is ready when the camera arrives. FlyToLocation sets its own destination, so you do not need it for flights.
using WPM;
using WPM.Planetary;
FlightPose now = globe.flightCamera.Pose;
Double3 next = PlanetCoordinates.ToPlanet(nextLatitude, nextLongitude, nextAltitude);
globe.AnticipatedView = new FlightPose(next, now.Forward, now.Up);
// When the view is reached
globe.AnticipatedView = null;
Scene View
The Scene view of the editor shows the tiles that the globe has loaded for the game camera, so the detail is where the game camera looks. The atmosphere and the sky are drawn only in the Game view. With the globe selected, the frame command (F) shows the whole planet. With the flight camera selected, it shows the place of the game camera.
When the scene has a globe, the Scene view shows the panel World Map Globe Ultra. You can move, dock and hide it like the other panels of the Scene view.
| Control | Description |
|---|---|
| Fit Window | Shows the whole planet in the Scene view. |
| View as Main Camera | Puts the Scene view at the place of the camera of the globe, looking the same way. |
| Latitude, Longitude, Altitude (m) | Place of the camera of the globe. When you write a value, the camera moves to that place and the Scene view shows it. These are the values of Location Settings, so the game also starts there. The change can be undone. |
Suggest an improvement
Help us improve this documentation page.