I have a house in my main level with a different level as its interior. I press E in a trigger box to Enter and Leave the building. Entering the Building is fine but, I want to have the player spawn in front of the building when exiting, How do I do that?
this question has been asked and answered many times before so im not going to go into detail, but the basics of it is that you need to have a variable that corresponds to the location you want to spawn when exiting the level. so for example in your level you have a player spawn location for when the level is begun for the first time (spawn 0) and a player spawn for each house (spawn 1, 2, 3, etc). so when you enter the house you would set a variable in the game instance (since it persist between levels) that pertains to the spawner you want to use on the return trip. so if you go in house 1 then you will want to use spawner 1 when you return, so when you load the main level on leaving the house you would have an event that fires to get the variable from the game instance and spawn the player at the associated spawner. this of course could be modified to just spawn the character at the default location then set their location after. you also need to think about if you want to have many exits from the house in which case you will need to be setting the variable from inside the house level and have 1 to 1 associated doors.
the pictures below show a little example of what i mean. the transporter blueprint is what you would have near a door to a house or anywhere where there would be a level change. the other blueprint is the level blueprint and basically just gets the variable from the game instance then uses that as an index to get an associated target point, then gets the location of that target point and moves the player there.
The Stuff you showed my doesn’t work. Maybe can you show my the variables, their types and the door instance?
Are you loading a new level when exiting the building? Do you not have a Player Start in your level?
ok well what did you do? what happened when you tried? what did you expect to happen but didnt? without knowing what your result was its not possible for me to be able to tell you whats wrong. provide more info man. did you find some of the other posts that go over this stuff?
as for the variables and their types it can pretty much be seen in the screenshots, levelToOpen is of type name, CorrespondingSpawnIndex is of type int, SpawnTargetPoints is an array of type targetpoint, and spawnindex is type int. the only thing in the doorsGameInstance is the spawnIndex variable.
i imagine the issue is that you either didnt set values for the variables, never set the game instance
as the one to be used in project settings, or didnt have valid actors as spawn locations.
Think of Skyrim, When you enter a house you leave the Main Level, and when you leave the house you spawn in front of the house.