How do i handle multiple enemies?


#1

Hello, so i start to a few days ago to use gdevelop and i dont know the bases of coding.
The problem: if i make multiple enemies, they take their own “health points”, they shot by their own each one, but if i try to display a text that shows their live, it creates two texts, but this text go to the “2nd” enemy and shows the live of the “1st” enemy,
by the way, on the top left corner there is an extra text with the same “code” but shows the hp of the “1st” enemy .


#2

In your action “put text around object”, GDevelop doesn’t know which text and object you mean.
In the block above, when you create the text, you can Link it to its object.
Then, use the link to tell GDevelop which text goes with which object.


#3

You mean the last one action?
but in that case, how do i difference the same object if i put two of them?


#4

It depends, sometimes you’ll want to use an instance variable, and sometimes, you’ll use the link. :slightly_smiling_face:
For this problem, you should use links.
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/linked-objects