Simultaneous Actions / Multiple Instances Question

Get help using Construct 2

Post » Mon Nov 11, 2013 5:29 pm

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



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.JH12013-11-12 16:06:50
B
7
S
3
G
3
Posts: 22
Reputation: 2,385

Post » Mon Nov 11, 2013 5:36 pm

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".
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Mon Nov 11, 2013 5:50 pm

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.



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.JH12013-11-11 17:57:22
B
7
S
3
G
3
Posts: 22
Reputation: 2,385

Post » Mon Nov 11, 2013 5:56 pm

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

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

Good luck!
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Tue Nov 12, 2013 4:04 pm

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.
B
7
S
3
G
3
Posts: 22
Reputation: 2,385


Return to How do I....?

Who is online

Users browsing this forum: adventurist, Blendi1223, PROxMTswatTR and 26 guests