Instance Variable set as variable

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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

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

  • Thanks for the quick response, will try it out!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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


  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)