How do I refer to an object's specific IID

Get help using Construct 2

Post » Tue Jun 30, 2015 8:30 pm

Hi everyone,

I would like to add the health (instance variable) of all the instances of one object type into one variable.

More specifically, I would like to do

Set totalHealth to enemy(IID#0).health+enemy(IID#1).health+enemy(IID#2).health

But I don't think it works this way. The only way I can think of is to pick each instance separately, and save the enemy's health into a local variable, do this 3 times, then add every value to each other...

Is there any way to do this more easily, using a code similar to the one I described above?
B
32
S
6
G
1
Posts: 353
Reputation: 2,821

Post » Tue Jun 30, 2015 9:09 pm

If it is all instances you need, then:
For each Enemy
->TotalHealth 'Add to' Enemy.Health
ImageImageImage
B
71
S
22
G
248
Posts: 3,759
Reputation: 138,069

Post » Tue Jun 30, 2015 9:20 pm

Sounds good, thanks a lot! I'll try it immediately.
I should definitely start to learn such tricks! ^^'
B
32
S
6
G
1
Posts: 353
Reputation: 2,821


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests