In the last tutorial, we created a map screen that the player can access when they leave their current location. But what if we want the player to be able to access it any time, with the option to close the map without visiting anywhere?
In this tutorial, we'll make use of AC's Player-switching features to rely on a separate "Map Player" character for the map screen.
Inside the Settings Manager's "Player settings" panel, set Player switching to Allow, and re-assign your game's Player prefab as the default:
For the map screen, we're going to rely on a separate Player character - so that the regular Player's position is unchanged until a new location is chosen. This Player need not be visible: an empty GameObject with AC's Player component is enough:
Assign this as a new Player in the Settings Manager, and then click the cog icon to the right and choose Edit start data.... This brings up the Player start data window for this new Player, which determines which scene they appear in:
Configure this window to have it reference your map screen scene. When the game begins, this Player will then be moved to the map screen.
In the previous tutorial, we used the Scene: Switch Action to enter this map screen. Here, we'll replace this with a Player: Switch Action that switches control over to this new "Map Player":
When switching Player character, AC will automatically switch to the scene that they're in - leaving the old one where we left them. This means that we could open the map from e.g. an Inventory interaction, so that we can have a Map in our inventory that the player can access in any scene.
The benefit with this approach is that we can now use another Player: Switch Action to return to our original Player character - and their previous location - should we wish to close the map without choosing a new location. This could be run, for example, when clicking a Button element inside a Menu that appears when the map screen is opened.
When we wish to visit a new location, we'll still rely on the old Scene: Switch Actions - we just need to precede it with a Player: Teleport inactive Action to bring the original Player into the map scene, and a Player: Switch Action to switch to them. This is to ensure that the new location scene's OnStart cutscene is correctly run when entering: