Here you'll learn the basic of how "UID" and "IID" works, also, how the health of the enemy works.
Who never tried to setup a rocket with smoke trail?
And who never stuck on it while thinking how to setup the smoke to coincide with the rocket when creating it?
All these issues are interrelated and the solution is very easy, you just need some principles.
UID and IID
When you run the game, it create all the objects placed on the canvas, giving them a Unique ID (UID) and a Index ID (IID). They will change when you destroy or create a new object on the canvas.
All the issues and a better explanation about these two is placed on the Manual.
"IIDs and UIDs in the editor don't change depending on the Z order, but they do change if you delete and insert instances. Because of this you should not rely on knowing UIDs or IIDs in advance at all - the instance with UID 3, for example, could change to a different object if you add or delete some things in the layout view. This could easily break your game or make it work differently "randomly" (it will seem random to many users because they won't realise certain things they did changed the UIDs and IIDs). For this reason I don't think UIDs or IIDs should ever be displayed in the editor, in order to discourage this bad practice."
As said, UIDs and IIDs are necessary for the Engine, but you don't need to rely at all about them.
Instead of using UIDs and IIDs, you should use conditionals where only the wanted object can meet.
Call it by encapsulate an object.
Let's start with a single example of a Rocket.
Resource file: Instance.CAPX
HTML5: Live sample
Open full size image
The procedure above show how to creating the rockets and place the smoke on their tail.
Every time the Engine create a new object, instead of picking their UID or IID (what can change on their life, and shuffle your ordering), it add +1 to a instance variable of a fixed object on your canvas, as an index.
The fixed object here is the text, but you can use an invisible sprite, or, a HUD object.
On created, the conditionals set to the rocket instance variable that index, giving him an unique ID instance.
Also, set the same index to the child smoke (child because the smoke 1 was created by the rocket 1, so, the rocket 1 is parent of smoke 1).
On destroyed, the conditional requires the smoke ID, and destroy only the smoke with the same ID of the rocket.
Because all the IDs are really unique, you don't need to rely about shuffling issues.
The same thing works with a HUGE amount of issues.
For example, when a Orc pick a weapon on the ground, now you can know what weapon was picked, because when you create this weapon, you'll give it the same ID of the Orc ID, then, when the Orc is destroyed, you can set to the weapon be destroyed too.
You can make a poker game, giving for each card an ID, where the ID can setup the frame position and show the right card. Now you can shuffle the cards without worrying about destroying them.
Make special rewards for Unique monsters and making him glow just turning an invisible effect to be visible when the variable ID meet a certain conditional.
And, my favorite, it works perfectly for achievements. ^^
All this explain what means "Encapsulating the Object", but still missing to explain about the health.
When you check if a rocket hit an enemy, them set the enemy life to subtract 1, you're encapsulating the event to that specific enemy.
I think it covered all the proposed on the title, sorry if it's too high language (it means poor language on the programming field) or garbage, but I'm surely it will help someone having their first contacts with Construct 2!
This is a new simple sample of card shuffling and instance IDs manipulation:
Dealing with multiply enemies, how you can set their ID and manipulate each one:
Download the CAPX
Unlock your full gamedev potential
Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!
Plus, it's got a lot of additional features that will help you save time and make more impressive games!