Move the view
The view is the part of the map you see. It has a centre, a zoom (how close it is, each step doubles the
size) and a rotation in degrees (Bearing in code; 0 puts north up). Places are
Coordinates, so you can pass a scene position directly.
Follow the player
map.Follow = player; // keeps the player at the centre
map.RotateWithTarget = true; // optional: the player's forward points up
Set Follow to null to let go. This needs a map baked from your scene, and while it is set the player
cannot drag the map.
Go somewhere
map.EaseTo(chest.position, zoom: 16); // animated; zoom, bearing and duration (seconds) are optional
map.Center = chest.position; // or jump there at once
EaseTo keeps the zoom and rotation you do not give. Its other form changes only what you name:
map.EaseTo(zoom: 15, bearing: 90, duration: 1). map.Zoom and map.Bearing can also be set directly,
and jump. map.ZoomIn() and map.ZoomOut() zoom one step, animated, for your own + and − buttons.
Show an area
map.FitBounds(campA.position, campB.position, padding: 40);
Shows the box between two opposite corners. padding is a margin in UI points, duration is in seconds.
Limit what the player can do
|
How far out and how close in the zoom can go. |
|
Keeps the view over the baked terrain: the player cannot drag past its edges. |
|
Keeps the view inside the box between two corners. It replaces |
|
Allow or forbid dragging, turning and the mouse wheel. All three default to on. |
Bounds hold the edges of the view inside the box. When the view is wider or taller than the box (zoomed far out), the box stays centred in it instead, so that the whole terrain can still be seen.
What the player can do
Drag with the left button to move the map.
Right-drag, or Ctrl + drag, to turn it.
Use the mouse wheel to zoom.
All three follow the CanPan, CanRotate and CanZoom switches.
Calls made before the map is loaded run once it is (see The Map View component).