Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Load Level and Change Player Spawn?

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?

Product Version: UE 4.19
more ▼

asked Jun 02 '18 at 05:02 PM in Blueprint Scripting

avatar image

44 4 2 8

avatar image ThompsonN13 Jun 02 '18 at 07:05 PM

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.

alt text

alt text

capture.png (233.2 kB)
capture1.png (201.9 kB)
avatar image Mrminecraftwizz1 Jun 03 '18 at 05:35 PM

The Stuff you showed my doesn't work. Maybe can you show my the variables, their types and the door instance?

avatar image ThompsonN13 Jun 03 '18 at 06:22 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Are you loading a new level when exiting the building? Do you not have a Player Start in your level?

more ▼

answered Jun 03 '18 at 06:52 PM

avatar image

729 10 8 13

avatar image Mrminecraftwizz1 Jul 09 '18 at 08:25 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question