How would I can set the same position in identical level? SOLVED!

Hello Guys! I need your help.

I am new to Unreal Engine 4 and I need help. I try to do one thing.
When a player steps into a trigger box it will open a new level, an identical level, and I need that player in the same position like before the trigger box in the previous level. If you know what I mean. How can I do that, please?

Thank you for your answers.

KEJRAK

I think I know what you mean. But I want it like… do you saw Stranger Things? He was in a normal toilet and then he had an episode of “The upside down” world… the toilet changed. I need something like this with two levels and the same position of the player.

229376-the-upside-down-s01-e08-ss-003.png

Put player start in second level where you desire it to be.

And if you’re opening same level then you should use set actor location on event begin play to where it needs to be, but perform branch check if player has touched collision box. Since variables reset everytime you load new level, you should use game instance or save game file to save touched collision box boolean variable

save the player position as a vector variable in the game instance then open the level and on begin play set the players location to the saved variables location. essentially you want to save the location to a place where its value will be stored between levels. the game instance is preserved throughout the entire play session, whereas the level, character, and some other blueprints are not (they get destroyed then recreated when switching levels).

I am sure he can do this just by putting player start object where he needs it to be

So he would put player start in 100 0 0 in the second level, it’s just hardcoded not procedural way

Exactly! But I dunno how to do this.

Watch this tutorials.

it sounds more like hes asking to be placed in the same position he was in within the previous level not just start both levels in the same location.

for example if he started level one at 0 0 0 but moved to 100 0 0 he would want his character to be at 100 0 0 when he opened the second level.

not if it could be a different placement each time you run the level. what if the trigger volume were 500 x 500 then having a set position to load the character wouldnt work. if its a begin overlap event what if the overlap was beginning on the other side of the trigger. or how about if he decided not to use a trigger box and just switch levels at a key press.

I agree that player starts would work for something like doors into a building which will never move or switching world zones. but when things are more dynamic you need a more dynamic solution. this also works easily into a saving system as well, as its a value likely to be loaded when loading any new level anyway.

It all comes down to what this person is most comfortable using. your way would work but mine would also. so in this case it comes to their needs and what they can make work. in scripting there are always many ways to accomplish the same thing.

first create a new game instance if you havent made your own yet. to do this go to your content browser and click the green add new button. then click the blueprints class option. in the search bar search for game instance and select the option below that says game instance then click select. name your new blueprint to something descriptive. now open the game instance blueprint. on the left side in the my blueprint tab look for where it says variables and press the + sign. This will create a new variable now name your variable to something like levelplayerlocation or something descriptive. go to the details panel on the right and change the variable type to vector. now you can close that blueprint and open your project settings (from main editor tab: edit → project settings). in the search bar search for game instance in the drop down here select the blueprint you just made. close project settings.

now this next step is slightly different if you are making your trigger its own actor or if your doing it in the level blueprint. I will assume its its own actor.

create a new blueprint actor (similar to how you created the game instance). open this actor and go to the components section at the top left and click the add component button. search for a box collision. with the box collision selected go to the details panel and scroll to the bottom. look for “on component begin overlap” and click the green button next to it. this will open the event graph. drag off the exe pin (white one) and search for cast to (have your player character class here). now connect the other actor pin on the begin overlap to the object pin on the cast node. this will cause the following script to be run only when the player enters the box.

now drag off the cast and cast to (insert game instance name here). drag off the object pin and search for get game instance. now drag off the other blue pin it will say “as ____” and search for the variable you created in the game instance (levelplayerlocation) select the one that says set before it. now you have a set node drag off the left most yellow pin on the set node and search for get actor location. then drag off the target and search get player character. now drag off the set node exe pin and search open level. in the level name box type in the level you want to open. go back to the main editor window and drag this actor into the level.

now we need to go to the level blueprint of the target level. to do this open the level you are moving to then click the blueprints icon just above the viewport and select the open level blueprint option. right click on the graph and search for beginPlay. drag off the begin play node and search for cast to (game instance name here). drag off the object pin and search get game instance. then drag off the “as (Gameinstance)” pin on the cast and search for your variable (levelplayerlocation) again but this time you want the one that says get. now right click on the graph again and search for get player character. drag off the blue return value on the player character node and search set actor location. connect the cast to the set actor location node and connect the variable to the new location. and your done.

the previous step could also be done on the character but it could cause issues when respawning

refer to the following pictures. it sounds harder than it is.

NICE! Thank you!

And very last Question. What about the camera? I tried to make a rotator and a vector with Player Camera Manager… but nothing worked.

PS: Sorry for that errors… I have fixed this already.

Okay… Looks it will work… but what if I don’t have any character yet… just capsule… Can I cast it on “Cast To CapsuleComponent”?

its not targeting a mesh just the character blueprint. so you could could create a new character and have nothing in it and it would work just fine.

It’s WORKING! THANK YOU VERY MUCH.

And one last thing. After this procedure, the player is looking left, but I stepped into it forward. It’s like, the player rotated about 90°. Is it normal?