One more question :D

Hello again.

I just need help with one more thing. I have a game where objects are created randomly, along with name tags (which are created 50 pixels above the objects). Then, the objects travel in a certain direction. The name tags travel in the same direction at the same speed.

This creates the illusion that these objects are linked, but they aren’t really linked, they just travel in a way that looks like that. And therein lies my problem.

When the main object, which is a tank, is destroyed, I have no good way of destroying the text along with it. I tried to “select the name tag nearest to the tank that was destroyed and destroy that”, but this does not work all of the time! For some reason, every 1/40 tanks will have their name tags continue towards the player after they die, which is weird.

I did a lot of testing, and I think this happens when a.) two tanks are destroyed at the same time, or b.) two tanks are very close and one is destroyed before the other.

Also, you should know that the tanks come from all directions towards the player.

I think the solution is to make the name an object of the tank when they are formed, but I have no idea how to do this? Any suggestions? Thanks!

Hi,

Using the distances between the objects is not a good idea.
GDevelop has an extension to virtually link objects. It’s useful to get the associated object from another one. In your case, you will create the name tags at the scene launch and “link” them to each objects. But this is only a virtual link, so you need to move the name tag according to the object it’s linked to.

I wrote a tutorial about that some months ago. Unfortunately, it’s in french. But you can try to translate it with Google or whatever and even download the example file provided at the end of it (it’s an example of multiple tanks having each their turrets).
http://wiki.compilgames.net/doku.php/fr/gdevelop/tutorials/association_objets