Hello, I know this question has been asked over and over again but I couldn’t find the answer I have been looking for so far;
I have an hallway and 2 rooms, I simply want to load a level whenever the player enters a room and whenever he/she decides to get back to the hallway I want the player be in exact position the door the player entered to.
Overriding Choose Player Start from game mode seemed like it would be too complex to deal with when I add a few more levels and PlayerStarts
I also tried Blueprint instance, couldn’t really manage to do it but I realized if I added an hallway that is independent from the first hallway, it would completely mess up the script.
Couldn’t really figure out how to use but I realized there is an option value in OpenLevel function and there is Tag in PlayerStart. I don’t know if they can be useful but just wanted to mention.
Any ideas about dealing with dozens of PlayerStarts from dozens of levels?
You will need to use a mix of tags and the Game Instance class. Game Instance is the only class that does not get destroyed when you open a level. EVERY other class (including game mode) gets destroyed and re-created, losing all its data in the process.
1 - Tag your player starts. i.e.: Level1_Start1, Level1_Start2, etc
2 - Your doors should be blueprints with a public name (or whatever type tags are, I don’t remember) variable. Each of your doors needs to know the tag of the player start they want to send the player to.
3 - Create a name variable in your Game Instance (you’ll need to create a custom game instance class first if you don’t have one, and then set it as your default game instance class in your project settings).
4 - When a player uses a door, get the destination tag name from the door blueprint and save it into the tag name variable in your Game Instance so it doesn’t get erased.
5 - Load your new level
6 - On the Begin Play of each of your levels, get that tag name from your Game Instance, search through every PlayerStart in your level for a matching tag, get the location of that matching PlayerStart, and teleport your player there.
Ideally you’d want to hide the teleporting process with a loading screen or black screen.