Im working on an rpg style game and am trying to travel from one level to another. but not just simple travel, like say you walk up to a door to a house you press e key it takes you to another level that is the interior of the house, i could set player start in the location i want to spawn but lets say the house has 2 doors and i want to link the front door to spawn play at certian location and same with the back door.? kind of like the elder scrolls oblivion.
you need a system where you set a variable in the game instance which represents the target destination in the new level. then when the new level loads you get this location and move the character there. you could probably also adapt this idea to using player starts as well. i actually just started working on a tutorial for this very thing so ill try to give a quick explanation on what i did. note i used a actor to begin the level transitions and as the target location in the next level.
first in the gameinstance create a variable “spawnlocation” of type string.
Next we create the transitioner actor which will act as the exit and entrance to levels (picture 1 below). the transitioner actor just sets the variable in the game instance then loads the next level. this actor has two variables which are set as public so that they can be set on a per instance basis.
the third step is to create a script that will run each time a new level is opened (picture 2). for this i used the game mode since its begin play is fired each time a level is opened, or put another way a new game mode is created for each level. this will allow us to write the script once and not have to use the level bp. anyway the script just gets all the transitioner actors then tests each one to see if its name matches the SpawnLocation variable from the game instance. if we find a match then we set the players location and break out of the loop.
the whole system is just a way to have two points associated in different levels. the pictures below show a basic example of the system. i also added the work in progress of the tutorial writeup.
thanks this works from going from second level to the first level but for some reason going from first level to second level player spawns in middle of map an offten goes through floor any ideas?