Fold variable of all instances

Get help using Construct 2

Post » Thu Jul 25, 2013 7:36 pm

Hi, constructers.
I`ve got planets with units on it (instance "planet", variable "unit") and now i need to get a total amount of units on all planets (all planets are the same object). Can anyone tell me how to do this or give some advice? (like "go get some sleep" :))

No-way-variants:
Every tick - Set global\local variable to planet.units.
Every tick pick all planets - Set global\local variable to planet.units.

I`m not a new at C2 but, whoa, now i feel myself like a noob.
B
8
S
2
Posts: 56
Reputation: 1,021

Post » Thu Jul 25, 2013 7:40 pm

One variable : All_Units

Every tick/every X second:
Set All_Units to 0
Sub event For all planets:
Add to All_Units planets.units

I think this should work
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Thu Jul 25, 2013 7:54 pm

Hey, thanks a lot, that`s almost it.
"Pick all Planet" doesn`t work, but "For each Planet" works perfect. All i needed is "Set All_Units to 0".

Karma and love to you :)
B
8
S
2
Posts: 56
Reputation: 1,021


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests