Simultaneous Actions / Multiple Instances Question

0 favourites
  • 5 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • [SOLVED BELOW]

    I'm having some trouble understanding why only part of my action sequence is working on all instances but the rest of it is not.

    <img src="http://i.imgur.com/Xs0J8E2.png" border="0" />

    Enemies randomly spawn on one side of the screen and the player can spawn his soldiers on the other via mouse click. Players/Enemies move towards each other and stop when they overlap, inducing the attack sequence show in the image for each Player instance, which continues until one of them has their Health reduced to <= 0. The remaining soldier then continues on.

    I've run this in the debugger, and instances of Player and Enemy are having their instance variable Health subtracted from simultaneously. I paused the debugger and checked the Health of multiple Player/Enemy pairings that were overlapping at the same time and found they all had reduced Health.

    However, the pair of text boxes (textAttack) I'm trying trying to generate above each Player/Enemy instance after they lose Health is only being created on one Player/Enemy pairing at a time.

  • Everytime I want pick all the instances of one object, I do "Pick All" and then the logic.

    Your code is selecting only the enemies overlapping the player, so, if you want the events running for each enemy, try "For Each".

  • Thanks for the suggestion. I tried a few variations:

    Pick All Player > Overlap > ...

    For Each Player > Overlap > ...

    Overlap > For Each Player > Every 2 Seconds > ...

    They didn't seem to change the outcome.

    <img src="http://i.imgur.com/9chpqri.png" border="0">

    This is taken from the last variation. The text only appears above the one overlap happening in the bottom right corner, and then moves onto another pairing once one of those is destroyed.

    Here's the capx. I'm not sure where my logic is wrong.

  • Well, I'll suggest for you the follow read:

    scirra.com/tutorials/361/understanding-uid-iid-health-cards-and-rocket-smoke-trail

    Good luck!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's been a while since I fired up C2 and my mistake was fairly basic. I should have had the object instances spawning the text object rather than trying to have the system create a new object at each instance's location.

    Thanks for the link, TELLES. It eventually led me back to a few searches and the correct info on picking instances.

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