Big problems with multiple family AI

Get help using Construct 2

Post » Sat Sep 14, 2013 11:52 pm

Hi friends. I'm trying to use families to create a series of events to work for multiple enemy instances, and it...KIND of works, but there are a lot of problems with it.
The patroling behavior right now seems to only be working for 1-2 enemies at a time. If you spawn only 1 enemy you can see that it works perfectly, but I can't get it to work on a bigger scale. I think i'm doing something terribly wrong with loops and families.

The CAPX:
https://www.dropbox.com/s/zqligiv6j532fwy/TheMachine0.6.capx
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Sun Sep 15, 2013 9:53 pm

bump
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Mon Sep 16, 2013 2:48 am

@Sushin,

That's quite a complex set of events (with some good ideas) so I hope I haven't misinterpreted your plan. I've taken a few minutes to look through it and I think I've identified a logic fault in your Enemies.IsAlert trigger check (line 13). I would recommend adding a For Each Enemies loop condition before the IsAlert check... Without it C2 will just check one instance of Enemies per tick rather than each instance in turn. That omission would cause the system to miss most of the pathfinding triggers etc.

I'll have another look to see if anything else stands out, but if you change that then you should see it work as you want.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Mon Sep 16, 2013 2:58 am

....or, as an alternative to the For Each... add the IsAlert check as a sub-condition of each of the event triggers that you have there - that should work as well.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Mon Sep 16, 2013 8:27 am

I agree exactly
B
2
Posts: 3
Reputation: 156

Post » Mon Sep 16, 2013 6:12 pm

@Colludium

Thanks for the tip, but I have tried that multiple times. It says that triggers cannot be a sub-event of loops. Here's the error message:

B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Mon Sep 16, 2013 6:31 pm

@Sushin - blast it! I managed to reproduce your error, if that's any consolation... I'll have a tinker with the other conditions but a quick copy-paste of the IsAlert condition into each of the triggers hasn't fixed the problem (it seems like only one enemy moves....).Colludium2013-09-16 18:33:38
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Mon Sep 16, 2013 7:01 pm

[QUOTE=Colludium] @Sushin - blast it! I managed to reproduce your error, if that's any consolation... I'll have a tinker with the other conditions but a quick copy-paste of the IsAlert condition into each of the triggers hasn't fixed the problem (it seems like only one enemy moves....).[/QUOTE]

Okay. Thanks for your time. I've been having a lot of problems with loops lately.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Tue Sep 17, 2013 2:54 am

@Sushin,

I think I've fixed it! Please bear in mind that I'm not sure of what effect you were trying to achieve, but it definitely does some good enemy AI type stuff now... The fix I found involved combining the enemy conditions into two groups, one For Each Enemies / IsAlert and one For Each Enemies / IsAlert(not).

I've come across similar logic inconsistencies as this in the past in C2 and they are always infuriating to figure or work-around (most have been my own doing, I must confess!). I thought what you had should have worked but I suspect C2 didn't like the multiple checks of each state (although my version uses 2 check loops of each Enemies group).

Here's my edited Capx so you can see what I've done. I haven't commented it but the group amalgamation should be kind of obvious. Hope this helps!

https://dl.dropboxusercontent.com/u/184657779/the%20machine%20edited%20by%20ed.capx
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Tue Sep 17, 2013 9:37 pm

[QUOTE=Colludium] @Sushin,

I think I've fixed it! Please bear in mind that I'm not sure of what effect you were trying to achieve, but it definitely does some good enemy AI type stuff now... The fix I found involved combining the enemy conditions into two groups, one For Each Enemies / IsAlert and one For Each Enemies / IsAlert(not).

I've come across similar logic inconsistencies as this in the past in C2 and they are always infuriating to figure or work-around (most have been my own doing, I must confess!). I thought what you had should have worked but I suspect C2 didn't like the multiple checks of each state (although my version uses 2 check loops of each Enemies group).

Here's my edited Capx so you can see what I've done. I haven't commented it but the group amalgamation should be kind of obvious. Hope this helps!

https://dl.dropboxusercontent.com/u/184657779/the%20machine%20edited%20by%20ed.capx[/QUOTE]

Well...it seems to work for a little bit, besides the fact that they won't rotate when they are patrolling, but if you alert a few of them and then go hide, they all simultaneously stop moving completely, patrolling or not.

I'm perplexed that it even works, considering the part where you have the "is not alert" loop as a subevent to the "is alert" loop...
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, dand, tinhofiel, Yahoo [Bot] and 28 guests