0 votes

Hello!
(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

Godot version 3.2.3
in Engine by (19 points)

1 Answer

0 votes

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.

by (7,148 points)

Sorry, what signal and what code do I need to connect?
gettree (). Changescene () 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

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.

If it is not difficult to send a working project

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

Thank you for helping!

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.