Map & Fast Travel

From RPG Creation Kit
Jump to navigation Jump to search

In this tutorial we are going to take a look at the new World Map and Fast Travel systems, features that came with Update 2.2.

The World Map allows the Player to open a map of the place he is in, see the locations he has discovered, place a custom marker and fast travel to any location he has already visited. Locations also show up on the Horizontal Compass, which is also what points the Player to his current quest objective, so in this page we will take a look at the compass markers as well.

As for most of the RPG Creation Kit, everything is data driven: a location is an asset, a marker placed in a Cell tells the kit where that location is, and the map images can be generated for you from your cells (or can be entirely custom).

How the World Map Works

The system is made of a few pieces:

  • World Map Location: an asset that represents a place the Player can discover and travel to, such as a city, a camp or the entrance of a cave. It holds the name, the icon and the discovery and fast travel settings of the location.
  • World Map Marker: a component placed in the cell scene of the location, on the exact spot where the Player will arrive when fast traveling there. Every time you save the scene, the marker writes its position (and its worldspace and cell) into its World Map Location, this way the map knows where every location is even when its cell is not loaded.
  • Map Images: every Exterior Worldspace can have its own map image, and every Interior Cell can have its own map as well (useful for dungeons and cities). Both are generated with the Map Texture Builder.
  • World Map Manager: the component that owns the rules, which locations are discovered, whether the Player can fast travel and how much time a travel takes.
  • World Map UI: the map screen itself.

The state of the World Map (discovered locations, custom marker, etc.) is stored in the Save File.

The World Map in Game

The Player opens the map with the Map action (M on the keyboard, D-Pad Up on the gamepad). The game is paused while the map is open, and the header shows the name of the place the Player is in together with the current in-game day and time.

111.png

On an exterior map you will see:

  • The Player: the orange arrow, rotated towards where he is facing.
  • The Quest Objective: the red marker, it shows where the objective of the current quest is (see Quest Objective Markers), as long as it is in the place shown by the map.
  • The Locations: every location of this worldspace the Player knows about. Hovering a location shows its name, clicking it asks to fast travel there. Locations that have been revealed but not visited yet are drawn semi-transparent.
  • The Custom Marker: a marker the Player can place anywhere on the map to remember a spot. Placing it somewhere else moves it, placing it on top of itself removes it. The custom marker is also shown on the compass while the Player is in that worldspace.

The controls are:

  • Keyboard & Mouse: Left Click on a location to fast travel, Right Click to place/remove the custom marker, drag with the Left Mouse Button (or use WASD/Arrows) to move around, Mouse Wheel (or -/=) to zoom, C to center the map on the Player, M, Esc or Tab to close.
  • Gamepad: the Left Stick moves a cursor (the map scrolls when you push the cursor away from the center), A to fast travel to the location under the cursor, X to place/remove the custom marker, LT/RT to zoom, Y to center on the Player, B to close.

The control hints on the screen update automatically depending on whether the Player is using the keyboard or the gamepad.

The map always shows the place the Player is in, there's no way to browse other worldspaces:

  • In an Exterior Worldspace, the map of that worldspace is shown.
  • In an Interior Cell that has its own Interior Map, that map is shown, but only with the Player and the quest objective on it. There are no locations and no custom marker on interior maps, which means that the Player can't fast travel from an interior through the map, he has to go outside first. Interior maps are only there to help the Player find his way.
  • Everywhere else, the screen simply shows "No map for this location".

The World Map Objects

Everything the World Map needs is already set up in the _WorldLoader_ scene (see World Loader), so you don't have to do anything to have it working in your game. However, it's good to know where things are, since you will probably want to tweak something:

  • [World Map]: the GameObject with the World Map Manager and the World Map Locations Database components.
  • World Map Canvas: the UI of the map, with the World Map UI component.
  • The Map action of the "Player" action map and the MapUI action map, in the RckPlayer_Actions Input Actions, in case you want to change the bindings.

Image33.png

The World Map Manager exposes the following fields:

  • On Location Discovered Sound: an AudioClip played when the Player discovers a location.
  • Travel Hours Per World Unit: how many in-game hours pass for every unit traveled inside the same worldspace. With the default value of 0.01, a travel of 500 units takes 5 hours.
  • Min Travel Hours: the minimum amount of hours a travel takes, no matter how close the destination is.
  • Other Worldspace Travel Hours: the hours that pass when traveling to a location in a different worldspace, since in that case the distance can't be calculated.
  • Min Travel Distance: if the destination is closer than this, the fast travel is refused with "You are already there.".
  • Arrival Height Offset: the height added to the position of the marker when placing the Player, since his pivot is above the ground. You shouldn't need to touch it unless you change the Player's controller.
  • Can Fast Travel From Interiors: if disabled, fast traveling is refused while the Player is in an Interior Worldspace. Since the map never allows to fast travel from an interior anyway, this only affects the fast travels started from scripts.
  • Block When Overencumbered: if enabled, the Player can't fast travel while carrying more than his Max Encumbrance.
  • Custom Marker Compass Icon: the icon of the custom marker on the compass. Leave it empty if you don't want the custom marker on the compass.

The World Map UI component holds the references to the UI elements and some visual settings, such as the Default Location Icon (used for the locations without an icon), the Undiscovered Location Color, the Open Zoom (how much the map is zoomed in when it opens), the colors of the Player and quest objective markers and the pan/zoom speeds for keyboard and gamepad.

Creating a New Location

Now let's create a new location the Player can discover and fast travel to. Let's say we want to add an old mill to our exterior world.

1) Open the Exterior Cell where the location is, for example from the Cell View.

2) Right click in the Hierarchy and select RPG Creation Kit -> World Map Marker. This creates a GameObject named "New Map Location" with the World Map Marker component. Rename it with the name of your location, "Old Mill" in our case, as it will be used in the next steps.

3) Move the marker on the ground, on the exact spot where you want the Player to arrive when fast traveling there, and rotate it so that the blue line points to where the Player should be facing when he arrives. Usually you want it just outside the entrance of the place, looking at it.

4) In the inspector of the marker press Create New World Map Location. A new asset named "[MAPLOCATION] Old Mill" is created in the same folder of the cell scene, with the ID "MAPLOC_VIRRIHAEL_OLD_MILL", and it is assigned to the marker.

4444.png

5) Select the new asset, you can set its Icon and the other settings (see the next section).

6) Save the scene. Saving the scene is what writes the placement of the marker into the location, the Console will confirm it with "World Map: updated the placement of 1 location(s)...". You can also do it without saving with the Sync Location Now button of the marker.

7) Run RPG Creation Kit -> Update All Databases (see Databases).

And that's it! Walk near the mill in game and you'll get the "Discovered: Old Mill" message, and from now on the Player will be able to fast travel there from the map.

6666.png

You can also create the location asset by hand, by right clicking in the Project Window and selecting Create > RPG Creation Kit > World Map > New Map Location, and then assign it to the marker. The result is the same.

Important: if you move the marker, remember to save the scene again, otherwise the location will keep the old position. The inspector of the marker always tells you where the location is currently placed, so you can quickly check if it is up to date. Also, use only one marker per location: every marker writes its position into its location when its scene is saved, so with two markers the last saved one wins.

Important: place your locations in Exterior Cells. The map only shows the locations of the exterior worldspace the Player is in, and interior maps never show locations. A location placed in an interior cell can still be discovered and used from scripts, but it will never appear on the map. If you want the Player to be able to fast travel to a dungeon, place the marker in the exterior cell, right outside its entrance Door.

When you update the databases, the Editor will warn you in the Console about locations without an ID, duplicated IDs and locations that are not placed in the world yet.

The World Map Location

4444.png

  • ID: the UNIQUE ID of the location, used by the database, the Save File and the scripting functions. You can generate a random one by right-clicking on the asset and selecting "Regenerate ID", but a readable one like "MAPLOC_OLD_MILL" is a lot more comfortable when you have to type it in scripts. Don't change the ID after releasing your game, the Save Files store the discovered locations by their ID.
  • Location Name: the name displayed on the map, in the "Discovered" message and in the fast travel confirmation.
  • Icon: the icon used on the map and on the compass. If it is empty, the map uses the Default Location Icon of the World Map UI and the location won't be shown on the compass.
  • Discovered By Default: if enabled, the location is discovered from the start of the game, so the Player can fast travel there right away (think of the city the Player starts in).
  • Discovery Radius: the Player discovers the location when he gets closer than this to the marker. Only the horizontal distance counts, the height is ignored.
  • Show On Compass: if enabled, the location is shown on the Horizontal Compass (see Compass Markers).
  • Can Fast Travel To: if disabled, the location still appears on the map once discovered, but the Player can never fast travel there. Useful for the places that should be on the map but that the Player should reach on foot, like the lair of the final boss.
  • Worldspace, Cell, Position, Y Rotation: the placement of the location. These are written by the World Map Marker, so you don't have to fill them by hand.

The World Map Marker

The World Map Marker only has one field, the Location it represents. In the Scene View it is drawn as a yellow sphere with a vertical line, so you can spot it easily, plus the blue line that shows where the Player will face when arriving. When the marker is selected, the Discovery Radius of its location is drawn as a yellow circle around it.

Its inspector shows where the location is currently placed and warns you when something is wrong, for example if the marker is not in a cell scene, if the location has no ID or no icon, or if it hasn't been placed yet.

At runtime, the marker is what discovers the location when the Player gets close and what puts its icon on the compass, so it only does that while its cell is loaded.

Discovering and Revealing Locations

For the Player, a location can be:

  • Unknown: the Player knows nothing about it, it is not on the map.
  • Known: the location has been revealed to the Player, for example an NPC told him about it or he read about it in a book. It is on the map, but semi-transparent, and its tooltip says "Undiscovered". The Player can't fast travel there until he visits it. When a location is revealed the Player gets a "Map updated: <name>" message.
  • Discovered: the Player has been there, it is on the map and he can fast travel to it.

A location gets discovered when:

  • The Player gets within its Discovery Radius. The "Discovered: <name>" message is shown and the On Location Discovered Sound is played.
  • It has Discovered By Default enabled.
  • The Player fast travels to it (only possible with a scripted travel, see Scripting the World Map).
  • It is discovered by a Consequence or by a script.

Revealing a location, instead, is something you can only do from Consequences and scripts, since it is always tied to your story.

On the compass, a location is drawn dark until it gets discovered.

Fast Travel

When the Player clicks on a location, the World Map checks if he can travel there. If he can, a confirmation panel shows up with the travel time ("Fast travel to City? It will take 3 hours."), otherwise the reason is shown in red on the map:

888.png

  • "You must discover this location before you can fast travel to it.": the location has been revealed but not visited yet.
  • "You cannot fast travel to this location.": the location has Can Fast Travel To disabled.
  • "Fast travel is currently disabled.": fast travel has been disabled by a quest or a script.
  • "You cannot fast travel right now.": cells are still loading, or the Player is in a cutscene, in a conversation or dying.
  • "You cannot fast travel from here.": the Player is in an interior and Can Fast Travel From Interiors is disabled.
  • "You cannot fast travel when enemies are nearby.": an NPC is in combat with the Player.
  • "You cannot fast travel while riding.": the Player is on a mount.
  • "You are carrying too much to fast travel.": the Player is overencumbered and Block When Overencumbered is enabled.
  • "You are already there.": the destination is closer than the Min Travel Distance.

Once the travel is confirmed, the map closes, the loading screen shows up, the destination cell is loaded and the Player is placed on the marker, facing its blue line. NPCs that are following the Player and have Follows outside of Cell? enabled (see Rck AI Editor) come along, exactly like they do when the Player goes through a Door.

The in-game time advances by the travel time, so everything that depends on the clock goes on as if the Player had walked (for example, Harvestables keep regrowing). The travel time is the distance between the Player and the location multiplied by the Travel Hours Per World Unit, and it's never less than the Min Travel Hours. For a location in another worldspace it is always the Other Worldspace Travel Hours.

The kit also remembers the last position of the Player in an exterior worldspace, so if a scripted travel starts from inside a house, the distance is calculated from where the Player was before entering it.

Creating the Map Images

The Exterior Map

The map of an exterior worldspace can be made by stitching together a top-down screenshot of each one of its cells or using a custom image of a map, like the one used in the Demo. If you plan to have a custom image, you can just set the "Map Texture" to that in the Worldspace asset and skip the generation.

1) Open RPG Creation Kit -> Cells System -> CellMapView and select your Worldspace. Set the screenshots folder (by default Assets/_CellScreenshots) and press Regenerate All (or select some cells to regenerate only those). The tool opens every cell scene and takes a top-down screenshot of it, so it might take a while.

V1.png

Note: the screenshots use the Time of Day Preview slider of the toolbar (see What's new in the RPG Creation Kit 2), so set it to a bright hour before taking them, unless you want your map to be at night.

2) Open RPG Creation Kit -> World Map -> Map Texture Builder and stay on the Worldspace (Exterior) tab. If you had your Worldspace selected when you opened the window, it is already filled in.

V2.png

  • Worldspace: the worldspace you want to build the map for.
  • Screenshots Folder: the folder with the screenshots of the CellMapView. It is shared with it, so normally you don't have to touch it.
  • Pixels Per Cell: the resolution of each cell on the map. The final image can't be bigger than 8192 pixels, so on big worldspaces this value is reduced automatically.
  • Missing Cell Color: the color used for the cells that have no screenshot.

3) Press Build Map Texture. The image is saved as "<WorldspaceID>_WorldMap.png" in the same folder of the Worldspace asset, and it is assigned to the Worldspace.

The result is a regular PNG, so you can open it with your favourite image editor and paint over it to give it a more stylized look, as long as you don't change its framing (don't crop it, don't resize it with a different ratio). Keep in mind that building the map again will overwrite it, so keep a copy of your painted version!

The map fields of the Worldspace asset are:

Imagev4.png

  • Map Texture: the image shown on the World Map for this worldspace. If it's empty, the map shows "No map for this location". It is ignored for Interior Worldspaces, interiors use the Interior Map of their cells instead.
  • Override Map Bounds: by default, the area of the world covered by the image is calculated from the cells grid, which is exactly what the Map Texture Builder produces. Enable it if you want to use your own image covering a different area, such as a hand-drawn map.
  • Map Bounds Min / Max: the world area (X and Z) covered by the image when Override Map Bounds is enabled. Min is the bottom-left corner of the image, Max is the top-right one.

If you draw your own map from scratch, remember that on the map the world +X axis points to the right and the world +Z axis points up, so the North of the map is the world +Z.

Interior Maps

Interior Cells can have their own map, displayed when the Player opens the map while inside of them. The image is captured from above, cutting away everything above a given height, so that the ceiling doesn't hide the rooms.

Interior maps are set on each Cell and not on the Worldspace because all the cells of an Interior Worldspace sit around the origin of the world, on top of each other, so a single image for the whole worldspace couldn't work.

1) Select the Cell asset of your interior and press Build Interior Map at the bottom of its inspector (or open the Map Texture Builder and switch to the Interior Cell tab). The button is only shown for cells that belong to an Interior Worldspace.

2) The scene of the cell must be open to capture it, if it's not, press Open Cell Scene.

Imagev55.png

  • Geometry: the area occupied by the cell (X, Z and the heights in Y), useful to choose the Cut Height.
  • Cut Height (world Y): everything above this height is not drawn. Set it between the floor and the ceiling.
  • Padding: the empty space added around the geometry.
  • Resolution: the size of the longest side of the image.
  • Light Intensity: interiors are usually dark, so a directional light pointing down is added while capturing. Set it to 0 to only use the lights of the cell.
  • Background Color: the color of the empty space around the geometry.

3) Press Preview and adjust the Cut Height until it looks right, then press Capture & Assign. The image is saved as "<CellID>_InteriorMap.png" next to the Cell asset and it is assigned to the cell, together with the area it covers. NPCs and particles are left out of the capture.

If you prefer a hand-painted map, you can capture it first and paint over the PNG, or assign your own image to the cell and press Fit Area Only (keep the current image), which only sets the area covered by the map from the geometry of the cell (plus the padding).

The map fields of the Cell asset are:

  • Interior Map Texture: the map shown while the Player is in this cell. If it's empty, the map shows "No map for this location".
  • Interior Map Bounds Min / Max: the world area (X and Z) covered by the image, set automatically by the Map Texture Builder.

Note: since there is a single Cut Height, an interior with more floors on top of each other can only show one of them on its map. This is another good reason to split big dungeons in more cells connected with Doors (see Worldspace).

Compass Markers

Imagevvb2.png

The Horizontal Compass at the top of the screen shows the directions, the current quest objective, the locations and the custom marker. Its settings are in RCKSettings.cs:

  • HORIZONTAL_COMPASS_ENABLED: enables the Horizontal Compass, true by default.
  • ROUND_COMPASS_ENABLED: enables the old round compass, false by default. The round compass can only point to the North and to the quest objective.
  • HORCOMPASS_MAX_DISTANCE_LOC_VISIBLE: the distance (300 by default) within which locations are shown on the compass. The icons get bigger as the Player gets closer, and they disappear beyond this distance.

Location Icons

You don't have to do anything special to have your locations on the compass: every World Map Marker adds its location to the compass automatically, as long as the location has an Icon and Show On Compass enabled. Undiscovered locations are drawn dark, and they turn white once discovered.

Since the icon comes from the marker, it is only shown while the cell of the marker is loaded. For a location in an exterior worldspace, the icon is shown while the Player is in that worldspace, while for a location in an interior cell it is shown only while the Player is in that same cell.

The Compass Location Component

If you want an icon on the compass for something that is not a map location (a landmark, a shrine, a point of interest...), you can add a Compass Location component to any GameObject of a cell:

  • Icon: the sprite shown on the compass.
  • Is In Exterior Worldspace: enable it if the object is in an Exterior Cell.
  • Worldspace ID: the ID of the worldspace the object is in, used when Is In Exterior Worldspace is enabled. The icon is shown while the Player is in that worldspace.
  • Cell ID: the ID of the cell the object is in, used for interiors. The icon is shown while the Player is in that cell.

The icon is added to the compass when the component gets enabled and removed when it gets disabled, so you can show and hide it just by enabling and disabling its GameObject (or with a Mutable). You can find some icons ready to use in "RPG Creation Kit/Scripts/Compass & Objective Marker/HorizontalCompass".

Note: if the GameObject of a World Map Marker already has a Compass Location, the marker uses that one instead of creating a new one, and it keeps its Icon if the location has none.

The Custom Marker

The custom marker the Player places on the World Map is shown on the compass as well, while the Player is in the worldspace of the marker. Its icon is the Custom Marker Compass Icon of the World Map Manager.

Quest Objective Markers

The red marker on the compass (and on the map) points to the objective of the Player's Current Quest, which is the quest the Player has selected in the Journal. To tell the compass where the objective is, place a Quest Stage Target component on the object the Player has to reach:

  • Quest: the Quest this target belongs to.
  • Quest Stage Index: the number of the stage (10, 20, 30...) during which the compass points to this object.

When the Current Quest is set to that stage, the compass starts pointing to the object. For example, in Your First Quest we wanted the compass to point to the Bandit Camp at Stage 20 and to Uriel at Stage 30: all we need is an object in the bandit camp with a Quest Stage Target set to Stage 20, and a Quest Stage Target set to Stage 30 on Uriel.

The compass can only point to objects that are loaded, so where you put your Quest Stage Targets matters:

  • For places, put them in the _PersistentReferences_ scene, under the Quest Markers object, so they are always available no matter where the Player is (see Persistent References). The Demo has a child for each quest in there, such as "[Quest] Just Another Delivery".
  • For NPCs, add the component directly on the NPC prefab (many NPCs of the Demo, like Mack001, have one). If the NPC is a Persistent Reference, the compass will follow him wherever he goes.

Scripting the World Map

Consequences

The Consequences System has three new types, under World Map:

  • Reveal Location (show on map): reveals the Map Location you set, so it appears on the map without being discovered. Perfect for a dialogue line where an NPC tells the Player about a place.
  • Discover Location: discovers the Map Location, so the Player can fast travel there right away.
  • Enable or Disable Fast Travel: enables or disables fast travel, based on the Fast Travel Enabled checkbox. For example, you can disable fast travel when the Player gets trapped in a dungeon by a quest, and enable it again once he gets out.

Conditions

The IsMapLocationDiscovered condition takes a Location ID and returns 1 if the location has been discovered, 0 otherwise (see Conditions System). You can use it, for example, to show a dialogue topic only if the Player has already visited a place.

RCKFunctions

From your scripts (see Scripting and RCKFunctions) you can use the following functions:

// Shows the location on the map without discovering it, pass false to hide the "Map updated" message
RCKFunctions.MapRevealLocation("MAPLOC_OLD_MILL");

// Discovers the location, pass false to hide the "Discovered" message
RCKFunctions.MapDiscoverLocation("MAPLOC_OLD_MILL", false);

// Returns 1 if the location has been discovered, 0 otherwise
int discovered = RCKFunctions.IsMapLocationDiscovered("MAPLOC_OLD_MILL");

// Enables or disables fast travel
RCKFunctions.SetFastTravelEnabled(false);

// Fast travels the Player to the location, returns false if the travel couldn't start
RCKFunctions.FastTravelToMapLocation("MAPLOC_OLD_MILL");

FastTravelToMapLocation follows the same rules of the map, unless you pass true as the second parameter to ignore them. This is what you want for paid travels like carriages and boats, which should work even towards locations the Player has never visited (and, since traveling to a place means visiting it, the destination will be discovered too). The only requirement is that the location is placed in the world.

If you need to react when a location is discovered, for example to start a quest, you can subscribe to the onLocationDiscovered event of the World Map Manager:

WorldMapManager.instance.onLocationDiscovered += (WorldMapLocation _location) =>
{
    if (_location.ID == "MAPLOC_OLD_MILL")
        Debug.Log("The Player found the Old Mill!");
};

The World Map and the Save System

You don't have to do anything for the World Map to persist. The Save File stores the discovered locations, the revealed ones, whether fast travel is disabled, the custom marker and the last exterior position of the Player.

Save Files created before Update 2.2 load just fine: fast travel is enabled and no location is discovered (except the ones Discovered By Default), so the Player will discover them again by walking by.

Demo

The "Virrihael" worldspace of the Demo has its map ready ("VirrihaelWorldspace_WorldMap.png") and six locations: City, Tavern, Guards' Outpost, Priests' Village, Bandit's Camp and Abandoned Mines. You can find their assets in "RPG Creation Kit/Demos/__RckDemo__/Worldspaces".

The CityInterior and TutorialsCave cells have their own Interior Map, so try to open the map while you're inside the City or in the cave!