Pressing the E key in front of a door to enter a new level

Hey guys!
I am currently making a game where i want to have kind of a door mechanic like cry of fear or 5th gen games like silent hill where i press the “E” key in front of a door to enter to a new level.
The problem is I am a complete beginner and I don’t know how to start. ):
If anybody can send full screenshot to how to make it I would be really thankful!
Sorry for my bad english!
Thank you for everyone who is trying to help me! (:

1 Like

I am lazy, so i asked chatGPT to solve your problem:

Prompt: “How would i make blueprint in unreal, that when i press and ia am next to door it loads next level?”

Creating a simple blueprint in Unreal Engine 4 (or UE5) to load the next level when you’re close to a door and press a key involves several steps. Here’s a basic step-by-step guide to achieving this:

Setting Up the Door Blueprint :

a. Open your project in Unreal Engine.

b. Right-click in the Content Browser to create a new Blueprint Class. Choose Actor as the parent class and name it BP_Door.

c. Open BP_Door and add a Box Collision component. This will be used to check if the player is close to the door.

d. In the BP_Door Event Graph, drag the Box Collision component into the graph.

Setting Up the Proximity Check:

a. From the Box Collision component in the graph, drag out and select On Component Begin Overlap. Do the same for On Component End Overlap.

b. For both overlap events, you’ll want to check if the overlapping actor is the player. Drag from the Other Actor pin of the overlap event and use a Cast To node, casting to your player character class.

c. After casting successfully (from the “As Your Player Character” output pin), you can set a boolean variable, e.g., IsPlayerNear, to true for Begin Overlap and false for End Overlap.

Setting Up the Level Change on Button Press:

a. In the BP_Door Event Graph, find the Event Tick or create one.

b. From there, use a Branch node (represents an if-statement) to check if IsPlayerNear is true.

c. While IsPlayerNear is true, check for a key press event. For simplicity, let’s use the “E” key. Right-click in the blueprint and search for “E key” and select the Input Key event.

d. After the “E” key event, use another Branch node to check if IsPlayerNear is true. If it is, then proceed to the level loading logic.

Loading the Next Level:

a. From the true pin of the last Branch, drag out and search for Open Level node.

b. Input the name of the level you want to load into the Open Level node.

Final Steps:

a. Compile and save your blueprint.

b. Drag and drop the BP_Door actor into your level wherever you want the door to be.

c. Ensure that the Box Collision is appropriately sized so that the player can easily overlap with it when close to the door.

Testing:

a. Play the game, approach the door, and press “E”. If everything has been set up correctly, it should load the next level when the button is pressed while close to the door.

Remember to have the required input mappings set up if you’re not using the direct key checks. The described method is a basic way to do this, and there are numerous ways to enhance or expand upon this, depending on your game’s requirements.

1 Like

Hey @Nawrot
Sorry to bother you but I have a guestion is it normal to look like this or I messed up something in the beginning because I just started it and I got a feeling that i maybe did something wrong.


A huge thanks for your help you are a hero and for sure you are going to be in the ending credit i don’t know how they say it but I am really thankful!

That is EVENT there, not EVENT_Dispatcher. Doing that setup with pictu4res, it may help. :wink:

Hi @Nawrot
I may be sound dumb but is it right or no?
Sorry for wasting your time but I am a complete beginner.

@Nawrot I think I found how to do OnComponent Begin Overlap Do i need to use the collison box settings or details or whatever the name is where if i press the green plus thingy where it says OnComponent Begin Overlap am I right?


I’m also relatively new to UE5, but from my understanding I think this is how you would do it. FYI - You would have to have input enabled on your character for this to work, just search up the node “Enable Input” and connect your player controller to it. One last thing, you would have to create the variable “Overlap Status” as a boolean as well. If you aren’t sure how to do that look it up! Hope I could help.

1 Like

to get the stock physics events OnComponentBeginOverlap, OnComponentEndOverlap, OnHit

in the hierarchy you can right click a SceneComonent that has a collider then in “Add Event” (you can also get the list by going all the way down the details window with the SceneComonent selected) and select the event you wish to add.

as a note: to have a OnOverlap type event fire “Generate Overlap Events” must be true for the collider, and to get OnHit “Generate Overlap Events” should be false.

1 Like

I got easier solution:

All is inside BP_Door actor, like chat said.

Box - is collision box component, set to overlap everything
Then i use get overlapping actors, and set filter to first person character (I use fps template), change actor class to your player character class.
Then i check if sixe of returning array is greater than 0, and it will be only if player character is inside collision box.

All that is done after you press “E” key.

I tried to use begin overlap and end overlap. but sometimes variable is messed and does not register end overlap (or i had bug in code). Yes AI suggest is player near. But then how near, is 100uu inside door volume or not.

It is simpler, to check only at key press.

Ps. For BP_Door set “recive player input” to player 0, else E key will not work.

PPS.
most proper way to do it (avoiding HARD referencing other objects, because once referenced they will stay in memory, and when they reference other actors, all that net will stay forever in memory, and it is quite easy to make most of level to reference each other actor and make 90% of level be never unloaded)

You make BP_Door actor or BP_interactiveActor.
When Key E is pressed you line trace or capsule trace either around player or right ahead of player, and check for BP_Door actors.
Then BP_Door actor should have blueprint interface where you tell door to slide or torch to lit up etc.
This way actors from level do not reference player or other actors, and will be unloaded

1 Like

this system is a bit more complex with Enhanced Input, where you can no longer just have random actors “listen” for input, as a mapping context needs to be registered.

and the Project Setting input method is fully deprecated starting in UE5.2

I would suggest something like interfaces (or a low level interactable deriving from Actor) that has functions that will be inherited for specific effects.

this way you centralize the input into the Character/Pawn that has the Controller.

2 Likes

@Nawrot @3catboi
If I use plane as a shape is it going to confuse the system?

Plane to trigger event or plane that represents door?

Model of door can be anything,

Trigger should be collision volume, it can be box, capsule and some more things.

plane that represents the door

Hello @Nawrot the easier solution that you sent me somehow does not work do I need to do somethingt in the BP_FirstPerson blueprint because whenever I press the "E " key it does nothing ):
Sorry for being really dumb but I just don’t get it i did the blueprint just how you sent me that screenshot and it does not work):
I use unreal engine 5.1

You need to

Make sure you did this step.

My code should always write something to screen.
either “You pressed E” or “Nobody AT Door!”

And setup your door and trigger this way, but inside BP_DoorActor.

Also really make chat gpt accout, login there, and you can ask it questions like “why pressing E does not work in blueprint actor?”. It would give you instante reply and hints where to check.

1 Like

@Nawrot Yea you are right i should get a chatgpt acc.

By the way I realized what was the problem thanks for the help that you gave me for real i was dumb because i looked into the unreal documents
and yea i just realized what was the problem.
I am grateful for your help and patience sorry if i angered you or something so yea thanks again!

Hey @gardian206
Thanks for the help i need to look into enhanced input because it works different a bit than the older version of unreal.
By the way you are going to be on the ending credit scene for helping me thank you again.

1 Like

Hey @3catboi
Thank you for your help and time i
appreciate it for real.
By the way you are going to be on the ending credit scene for helping me out i hope i shown my gratitude towards you.

1 Like

No problem! Are you going to release your game on steam once it’s done because I will wishlist it and get it once it comes out!

Hi @3catboi
Sorry for the late reply! ):
Well idk really because this is my first game that i try to make so i will see
but i probably try to release it there but its not going to be the best game because i am not the best at level designing and so on.
But I will keep you informed. I am happy for your enthusiams and thank you again. (:

1 Like