0 votes

Hello Godot community !

I'm working on a game where the player has to collect "light fragments" in order to complete the level. Right now when the player has collected enough of them, the altar lits up when the player goes near it (see the image below).
However I would like for the player character to play the "level complete" animation after pressing a certain key on the keyboard while he is in the body area of the lit altar but can't figure out how to do it with code as Input.get_action_strengh in the player script and the altar script doesn't do anything. Could someone please help me with that ?

(My player character uses an animated sprite where all the animations are stored and I can't figure out if it's possible to get those animations from the altar script attached to the altar scene.)

Here's the image

in Engine by (32 points)

1 Answer

0 votes

I not sure that's the best way, but you can try something like this:
- In the player script create a signal
- When input clicks the button emit that signal
- Connect the area_entered signal of the altar with a function on the altar script
- The area_entered has a argument that is the object that collide with, in this case will be the player, connect the the signal of player with a function on the altar.
- Do whatever you want in this function.

In this case, when you press the key, the player will emit a signal and this signal will trigger the function in the altar.

by (171 points)
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.