Big problems with multiple family AI

0 favourites
  • 13 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • 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:

    dropbox.com/s/zqligiv6j532fwy/TheMachine0.6.capx

  • bump

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I agree exactly

  • 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:

    <img src="http://i.imgur.com/NbU3nIP.jpg" border="0" />

  • 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....).

  • 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....).

    Okay. Thanks for your time. I've been having a lot of problems with loops lately.

  • 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!

    dl.dropboxusercontent.com/u/184657779/the%20machine%20edited%20by%20ed.capx

  • 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

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

  • Yeah - not sure what's going on there. I couldn't get it to do anything with the loops properly separated. Some logic checks are obviously being missed by C2 and I'm struggling to identify a fix. Sorry to not be of more help...

  • Yeah - not sure what's going on there. I couldn't get it to do anything with the loops properly separated. Some logic checks are obviously being missed by C2 and I'm struggling to identify a fix. Sorry to not be of more help...

    It's fine. Thanks for helping as much as you did.

    I actually ALMOST have it working by removing all the loops and else statements between "is alert" and "is not alert"

    The only problem left now is that they don't go back to patrolling. I think the for each loops were actually redundant...

    EDIT:

    Okay..actually I just fixed it by starting their patrol timer in the same event that they go unalert.

    I read up on Construct 2 events this morning and thats where I got the idea to get rid of the for loop. Construct 2 already loops through all the       instances by itself.

  • Sushin,

    Glad you fixed it - I think I'm going to re-read the event section of the manual as well. It's interesting that such an apparently logical step could cause such a glitch. Every day's a school day...

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