Clone enemies that take separate damage? oh boy :(

0 favourites
  • 15 posts
From the Asset Store
🙌 J-BoB Damage & Hit Sound Pack comes with 585 high-quality sound effects
  • I feel like I'm making too many posts haha but the answers I'm after weren't in the manuals.

    Simple concept. I want to make an enemy and then be able to ctrl+drag clone them all over my platform for really easy level building but the problem I'm running in to is they all have the same global variable and when one dies they all die.. Hero's best case scenario but programmers worst nightmare.

    Any thoughts?

    thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I feel like I'm making too many posts haha but the answers I'm after weren't in the manuals.

    Simple concept. I want to make an enemy and then be able to ctrl+drag clone them all over my platform for really easy level building but the problem I'm running in to is they all have the same global variable and when one dies they all die.. Hero's best case scenario but programmers worst nightmare.

    Any thoughts?

    thank you.

    https://www.scirra.com/manual/73/instance-variables

    Instances variables are what you are looking for, Just create it for your ennemy, and use it instead of a global variable

  • [quote:3twlcmct]

    scirra.com/manual/73/instance-variables

    Instances variables are what you are looking for, Just create it for your ennemy, and use it instead of a global variable

    Thank you, I was just thinking this was the same sort of thing I will need to use on my "ammo".

  • Use instance variables for things each enemy "own"..

  • [quote:1mjlldp7]

    https://www.scirra.com/manual/73/instance-variables

    Instances variables are what you are looking for, Just create it for your ennemy, and use it instead of a global variable

    Thank you, I was just thinking this was the same sort of thing I will need to use on my "ammo".

    Well, everything is working awesome now but I'm not able to reference the instance variables in text boxes. At least I don't know how anyway. I'm working on a project where I need to visually see the "Health" of the object/enemy. With a global variable I was able to easily reference the value with the "Set Text" action but for whatever reason the instance variables are not able to be called the easy way. How do I make the instance values show up in the text boxes <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad" />?

  • I'd like to ask a further question.

    If I want 5 enemies to randomly have health between 20 & 30, can I set an instance value of Health 20, and then set an event random command to give the individual enemies randomly different health?

  • Well, everything is working awesome now but I'm not able to reference the instance variables in text boxes. At least I don't know how anyway. I'm working on a project where I need to visually see the "Health" of the object/enemy. With a global variable I was able to easily reference the value with the "Set Text" action but for whatever reason the instance variables are not able to be called the easy way. How do I make the instance values show up in the text boxes ?

    You need to "pick" the objects which instance variable you want to display first. If you just do a set text how should it know which value to display if all your instances have different values

    There are a lot of post on picking in the "How do i FAQ" (sticky at the top of this forum)

    You pick and instance and then use the instance variable.

    If you want to display text or a hp bar for each individual object you can do something like this:

    https://www.scirra.com/forum/viewtopic.php?f=147&t=97297&p=743346&hilit=individual+health+bar#p743346

  • Doc AI

    Can you help me? I have the same problem (already using instance variables)

    TheSynan

    Set text to

    ObjectName.InstanceVariable

    Sample:

    Object name = Enemy

    Instance variable = Life

    Set text to

    Enemy.Life

    or you want a word before it

    Set text to

    "Enemy's life = " & Enemy.Life

    I'm not sure which instance it will pick the instance variable from (if you have multiple instances of enemy object), but that should work.

  • I'd like to ask a further question.

    If I want 5 enemies to randomly have health between 20 & 30, can I set an instance value of Health 20, and then set an event random command to give the individual enemies randomly different health?

    Yes you can. You set the default value when you create the instance variable, but the individual objects can have individual independent instance variable values (which you can change whenever you want for each individual object seperately).

  • sgn15 have a look at the post i made just before you posted yours

  • cvp

    ok. thanks.

    Can you reply in my thread too?

  • cvp

    ok. thanks.

    Can you reply in my thread too?

    you mean this: Comparing X coordinates of player and enemy?

    I briefly looked through it, but the wall of text stopped me

    Think you should post a small capx that has your error inside it, then its much easier to look at and debug instead of reading a lot of text and not quite knowing what you want to achieve. (thats just my personal preference, i like to look at a capx, makes it easier to answer questions)

  • I think picking is one of the most fundamental and important aspects of construct 2. There is already a ton of explanation in the forums and in youtube videos (especially off reddit lessons which are awesome) but still it could be nice if there was an easier way to teach newcomers how to "pick"

  • cvp

    Windwalker

  • > I'd like to ask a further question.

    > If I want 5 enemies to randomly have health between 20 & 30, can I set an instance value of Health 20, and then set an event random command to give the individual enemies randomly different health?

    >

    Yes you can. You set the default value when you create the instance variable, but the individual objects can have individual independent instance variable values (which you can change whenever you want for each individual object seperately).

    Cool, thx. I'll keep this in mind for when I get that far (just learning the program at the moment).

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