Changible player map start point

Hi guys

I want to create a map which contains different rooms, all which will lead to different maps, however I would like to be able to get back to the original map from these and for the player to start at the door to the map hes just left, rather than from the original player start of the map.

e.g a street map, in which you can go into the a house (which would be s separate map) and return back to the street but outside the house you’ve just left.

Any ideas on how i would do this

I’m using blueprints and 4.13 for this



The usual solution is to use the GameInstance, either via blueprint or C++.
The GameInstance stays alive even when changing levels so all data you want to transfer between levels (player health, inventory, but also where to spawn on the next map) you can store there.

I assume you are using a trigger box for changing levels or something smilar that fires off an EventActorBeginOverlap.

  1. Create a new BluePrint Class, as parent class take “TriggerBox” and name it something appropiate, like “LevelTriggerBox”.

  2. Open the leveltriggerbox blueprint, create a new variable “whereToSpawn” from type name and make it editable.
    Now you can place levlechange triggerboxes and, in the Detail menu of that actor, give them text information what spawnpoint to look for when spawning the player in the next level.

Example: You have two maps, an “outsideHouse” map and an “insideHouse” map.
The “outsideHouse” map has two leveltriggerboxes for entering that house : “enterMainDoor” and “enterBackdoor”.
The “insideHouse” map has two spawnpoints : “startMainDoor” and “startBackdoor”
Give the “enterMainDoor” leveltriggerbox-“whereToSpawn” variable the text “startMainDoor”.
Give the “enterBackdoor” leveltriggerbox-“whereToSpawn” variable the text “startBackdoor”.

  1. Then, give your GameInstance a “whereToSpawn” name variable (if neccessary, create your own BlueprintClass from GameInstance as parent class so you can add as many things as you like to it. Don’t forget to set your project settings accordingly so the new game instance blueprint is used).

  2. When colliding with your levelchangetriggerbox have the EventActorBeginOverlap :

  • get the GameInstance
  • cast it to your GameInstance (so you have access to your custom “whereToSpawn” variable)
  • store the content of the “whereToSpawn” name variable from the triggerbox in the “whereToSpawn” variable from the GameInstance.
  • change the level to the next map

Ok, now our GameInstance stored information which player start to look for when opening the next map.

  1. In the level where the player will spawn in, you can make it so when the level begins to play (Event BeginPlay), get all actors of class “player start” (getAllActorsOfClass), search through them (foreach loop) and compare it (equals name) to the name stored in the GameInstances “whereToSpawn” variable. If you have found the correct player start actor, get the location of it and set the player actors location to that.

Example :
Player on the outside map enters triggerbox with whereToSpawn content “startBackdoor”. “startBackdoor” gets stored in the GameInstance. Next level loads. On BeginPlay event, the next level searches for all player starts, then picks the one named “startBackdoor” and moves the player there.

In short : Basically give your triggerbox a “whereToAspawn” attribute with the content being the same as name of the corresponding player start on the next map.
When overlapping with that level change trigger, save that attribute to your GameInstance. Have the next level read that saved attribute from your GameInstance and search for player spawns with the same attibute content in the level to set the players location/transformation accordingly.
And as a reminder : If you create your own GameInstance blueprint, don’t forget to set your project settings accordingly, otherwise the default GameInstance will be used and your “whereToStart” variable can’t be set/read.