Plans for automatic "pick instance UID" system?

0 favourites
  • 11 posts
From the Asset Store
Automatic screen resizing
$1.25 USD
50% off
Save hours of work by resizing items on your game screens.
  • I have yet to successfully make a game where one of multiple instances of the same type can be destroyed.

    example:

    player shoots one of the seven attacking drones. Drone has 5HP.

    When player has hit the same drone 5 times, all drones are destroyed.

    quite a few times I have started making a game where this is needed and every time I end up scrapping the project because I can�t figure it out.

    Have been searching the forum but can�t find a explanation or tutorial detailed enough.

    Some of the projects I ended up making with other game making software where this handled automatic. But overall I prefer C2 and that�s the reason this post.

    Thanks

  • You probably just need to use a "For each" loop when checking your Drone's health. That way it checks every instance's HP individually and only deletes the currently picked object in the loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • C2 already can do this. Give the enemies an instance variable and call it "hits". Then use two events like this:

    Bullet collides with enemy:

    ----- add 1 to Enemy "hits"

    ----- destroy bullet

    Enemy "hits" >=5

    ----- destroy enemy

  • Problem is that every time one of the drones is hit all of them suffers HP loss. A for each loop would make no difference

  • The loop is probably not needed, are you using instance variables?

  • how would that work different than:

    Bullet collides with enemy:

    ----- subtract 1 from Enemy "HP"

    ----- destroy bullet

    Enemy "HP" <=0

    ----- destroy enemy

    it�s the same thing

  • If "HP" started at 5 then yes it is the same.

  • What you just wrote should work fine:

    SubtractHP.capx (r116)

  • What you just wrote should work fine:

    SubtractHP.capx (r116)

    hmm.. now I?m more confused <img src="smileys/smiley5.gif" border="0" align="middle">

    I?ll check something be back with an update...

  • Ok, think I got it. Seems it had something to do with how I used "families". Gonna have to look into that a bit further. Thanx a million for the help..

    Hmm this thread should probably been posted in "How do I.." considering how it turned out.. sorry about that

  • If you put all of your baddies into a family called "baddies_family" let say.

    Then select the family in the project list on the right hand side.

    then add a family instance variable eg: health on its properties on the left hand side of the screen.

    then you use

    bullet on collision with "baddies_family"

    ->subtract 5 from "baddies_family" health

    it will only subtract the health from the specific baddie in the family it hit.

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