Instance Variable set as variable

Get help using Construct 2

Post » Thu Oct 15, 2015 8:33 am

As the title says:
How do i set an instance variable with a other variable (as initial value).

Explanation:
I used the template Towerdefense and made it a lot bigger (only events). Now i want different waves, which i got worked out. The only thing still unsolved is the Enemy.Health instance. Which is 30 by default. Now i want to change it to another value but somehow i can only get it to work for the first 2 mobs, after that it uses the 30 instead of the 40 i wanted.
Setting it with an event didnt work out for me, because it or changes only the first 2 mobs or resets the hp every event-run to 40...

ps.
(if you want to see for yourself, look at MainEvent->Enemy Control->Wave 1)
pss.
Cant add urls it seems
psss.
drive.google .com /file/d/0B4K61HkbX7LGY0tqNEE2N0lwMkk/view?usp=sharing
B
3
Posts: 4
Reputation: 189

Post » Thu Oct 15, 2015 9:01 am

When you spawn your enemy in the "enemy" group (event 19 I guess), spawn it and set its instance variable health value at that moment, according to the wave you are in.
To do so, you can set a global variable that you modify at each wave and set the value of the instances out of.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Thu Oct 15, 2015 9:13 am

Thanks for the quick response, will try it out!
B
3
Posts: 4
Reputation: 189

Post » Thu Oct 22, 2015 2:05 pm

Sadly i cant find a way to set the initial value through a global/local variable. If you know any way to do it, please tell. (When i use on to set it every spawn, it resets all active instances to that value, meaning that the first spawn/instance was damaged and would be healed/reset his hp)
For now i use pick #th instance, to set the hp. (Every spawn would +1 to variable that the #th function would use). It's not very nice/clean/neat that way :(

Update:
The #th doesnt work correctly, trying to set 5th instance while 1creep died (setting all others instance number 1lower xD ), trying to workout a way for that.
Update2:
For some strange reason it suddenly works.... Just setting the value to a certain hp... the reason why? no idea xD

New link for updated project for the interested:
drive.google .com/file/d/0B4K61HkbX7LGc2tXWDFXTXh4S1E/view?usp=sharing
B
3
Posts: 4
Reputation: 189

Post » Thu Oct 22, 2015 2:43 pm

something like:

enemy on created
> enemy set health : 30 + 10*TDWaveNumber

should make the health for

wave 0 - 30
wave 1 - 40
wave 2 - 50

etcetera..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Oct 24, 2015 1:31 pm

For some reason i never got that to work. It simply ignored the fact ->On created.
But it works now, and i don't know why xD

Going to research why and how, want to know :)
B
3
Posts: 4
Reputation: 189


Return to How do I....?

Who is online

Users browsing this forum: richcoz81, Yahoo [Bot] and 32 guests