enemy UID

How do I tell game develop to move an object towards a specific enemy that I clicked on? Right now if I have two instances of an enemy, clicking on the first one would direct the misile towards the second one.

Maybe you could create an object at the target position, or remember the target position as variables stored inside the missile?
Then you just have to move the missile toward the position stored inside its variables (or toward the target object) :slight_smile:

I attached a file which shows a method for doing this. I used this method for every game so far and it worked fine.
specific_enemy_example.rar (7.36 KB)

Beautiful solution! Thank you :slight_smile:

Actually both solutions are pretty nice and educational!

Do you guys think gamedevelop should have instance UID like construct2?

We should collect all these examples at a tutorials section of the website. :smiley:

Btw I notice that the ID of enemy is a variable that is created in the event sheet and not shown in the properties editor. I didnt know you can do that in gd. Construct2 sort of forces you to always create the instance variables in advance in the properties editor- before you can use it.

It’s better to declare it anyway.

I also gave every enemy an ID, but you don’t actually need it for this case. However, if you wanted to make say, a homing missile, then you give the ID of the enemy to the Variable(target) of homingmissile and then every x seconds adjust the stop the homing missile and add a force to move to object enemy that has Variable(ID) = homingmissile.Variable(target). If that makes sense?