Level up as a 2D platformer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaxTuz

(Sorry for my english, I used google translate)
How to make sure that when a player takes an item (key), the door opens and when the player approaches an open door, he goes to the next level

:bust_in_silhouette: Reply From: exuin

You’re actually asking multiple questions here.

To open a door when an item is picked up, you’ll have to connect a signal from the key to the door. You can do that either through the editor or through code.

To have the player go to the next level, you’ll want to change the scene. The easiest way to do this is to use get_tree().change_scene() with the path to the scene’s .tcsn file passed to the scene-changer function.

Sorry, what signal and what code do I need to connect?
get_tree (). Change_scene () I know, but how to make sure that the player does not immediately approach the door, but first takes the key, and then goes to the door
Sorry I’m new to Godot and just want to learn how to do simple things. thank you in advance

MaxTuz | 2021-01-11 15:55

If you’re new to Godot, you might want to check out some tutorials. There are also some demo projects, too.

If you’re asking how to make sure that the player gets the key before approaching the door, I think that the door being closed will ensure that the player looks for a key to open it.

If you’re asking how to open the door when the player picks up the key, you should either create a custom signal for the key and then connect it to the door through code, or you should call a function that opens the door when the key is picked up.

Sometimes it’s easier to see an example than to have it be explained with a bunch of text, so if you’re really stuck I can send you a working example project.

exuin | 2021-01-11 17:41

If it is not difficult to send a working project

MaxTuz | 2021-01-12 06:44

okay when I have time i’ll set up a demo

exuin | 2021-01-12 07:54

Thank you for helping!

MaxTuz | 2021-01-12 08:56

okay i set up a demo
it’s very unpolished so just look at the code
enter link description here

exuin | 2021-01-13 19:29