0 votes

I made a node with enemies node as the children of it, I want to make that if player already killed/freed all the enemies it will move a label node to the last enemy node position that get killed.

Here's my scene:



Enemies is a node2D
Slimes are Area2D

Godot version 3.4.4
in Engine by (17 points)

1 Answer

+1 vote

It would depend on some things in your game for example will there be different numbers of enemys or will it always be five?

One possible way this could work would be to have a script on the Enemies node and a script on each slime node. In the slime node when it is killed send out a signal to say it died and in the enemies node have a script listening to those signals which counts how many times an enemy has been killed. If the signal also sends the slimes global position then when the enemy script detects the last one was killed it could use the global position to add the label.

by (2,997 points)

Oh yeah my bad, Slime 1-5 are the same node, just duplicated, they all have the same script, each of them are placed differently in the scene, and player can choose to kill which slime first. I'll try your suggestion, Thank you so much!

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 Frequently asked questions and 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 [email protected] with your username.