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).

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...

(if you want to see for yourself, look at MainEvent->Enemy Control->Wave 1)
Cant add urls it seems
psss. .com /file/d/0B4K61HkbX7LGY0tqNEE2N0lwMkk/view?usp=sharing
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 !
Posts: 7,358
Reputation: 73,460

Post » Thu Oct 15, 2015 9:13 am

Thanks for the quick response, will try it out!
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 :(

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.
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: .com/file/d/0B4K61HkbX7LGc2tXWDFXTXh4S1E/view?usp=sharing
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

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
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 :)
Posts: 4
Reputation: 189

Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 11 guests