Pressing a Key in front of a door to enter in a new Map

I’m creating a game with a main outside level and some interior ambient levels. The idea of the game is look like some old 5th gen games, like Silent Hill, where do you press a key/button in front of a door and you get teleported right to the other side of that wall, without any opening door animation, but a black and quick load screen.

Doing it inside a map looks a kind of easy, but right now I want to do it between levels. My door is in the outside map, I want to press the key “E” in front of the door to make my character appear inside the place, exactly where the door should be inside.

This is how I want it to work. Press E in front of the silver door behind the chimmey to appear in that room. Press E in front of the red door to appear under the stairs.

Well, I don’t even know how to start. I already tried some stuff with Blueprint that I found searching here in the forum, but it didn’t help me.

I would recommend using a blueprinted gameinstance and playercontroller in order to achieve this, as well as a few well placed PlayerStarts. You can use the standard ‘open level’ node to get to you new level, passing an index that points to which player start you want to spawn on to your game instance depending on which door you used. After the level loads be sure to place your player at the proper playerstart and you should be good to go.

This is what I created in here, and of course, it didn’t work.
I can use the door as the teleport blueprint trigger or I should create a trigger box where the character must be inside when I press the E key?
Like I said, I don’t even know how to start this.

This may not be the best way, but you could use a game instance, a door actor, and your level blueprints to start off.
The game instance would need an integer value to identify the door you will arrive at in the new level.
For your door blueprint it could look something like this:

Here we check if the player is in range, then we set the target for the next level by changing the variable in our game instance and move the player to the next level.
Then your level blueprints would have to look something like this:

Here we loop through all of the doors you have set in the level, and we check if we have a match from the door we came in from. If we do, we move to a child component’s position and rotation so that we don’t spawn inside the door itself.
You will need to fill out your variable defaults, set up id’s for your doors, as well as target id’s to match the door id’s of the level you move to.
Hope this helps!

Hey man, thanks a lot! I understood the logic. But I have a really little newbie problem: In the “Set Door Id” there is a node for “Target”, how can I create that node?

That variable is in his MyGameInstance BP, hence he needs to reference that BP in order to set the Door ID

Sorry. I couldn’t found where it is or how I can create it.

It will work this way? I’m using UE4 in Portuguese, so some words are translated, like “SET” to “DEFINIR”.

That way will not work. You want to cast to your own game instance, inside that game instance’s blueprint you need to declare a public integer variable, which you can then set in the way my blueprint did.

My problem right now is: when I create a node from “As Game Instance” I cannot set a variable for the Door Id. It simply does not show my variable when I write “Set”.

First you need to creat your own GameInstance blueprint. Then you can create the variable you will get later. Here is a shot of the variables in MyGameInstance

38204-mygameinstance.png

Here is an example of how to get that variable later.

Beyond this, I would highly recommend looking up some documentation and watching the some tutorial videos on blueprints. They are filled with valuable knowledge that will save you a million headaches.
I wish I knew Portugese so I could help you better understand everything that is going on here. I hope that what I have given helps!

Perfect!! Thanks a lot, now I got it. I will do some tests with the IDs now.
Sorry to ask too many questions, but for now, you will certainly be in my game credits haha

This is the door outside, the blueprint exactly as you did and the values of the variables.

This is the door inside the map “1floor” and the Blueprint for “1floor”.
The GameInstance that I created just have the variables. In the three BP the value for all the variables are the same.

And, it didn’t work. I put my character in front of the outside door, I press the E key, but nothing happens.

In your OnComponentBeginOverlap event you need to set PlayerInRange to true, it currently is being set to false.

Still not working /=

In the Level Blueprint. In “Get All Actors of Class”, the Actor Class is of the door from the outside or the inside?
And the “My Id” variable, works for what?

The actor class in an ideal situation would be the same class for all of your doors, they may have different models and textures, but they all stem from that class. The My Id variable is the id that you assign to the door, give it a default value like 1 or 2 or 0, but make sure you set your target id in your other door to match it.

Ok, now I figured out that when I delete MyGameInstance from the BluePrint, it works, but the character do not start the new level where it should be. I think the problem is with the GameInstance.

It works fine .I think you dont have change your GameInstance in your Project settings