Trouble with Families and AI

This forum is currently in read-only mode.
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Im using Fammilies for my Ai in the code so I dont have to reprogram the Ai for each enemy type. Right now I am using a modified version of Deadeye's example http://www.scirra.com/phpBB3/viewtopic.php?f=4&t=1949&start=60 Here is a picture of the code as I have it now the problem is that When I make multiple instances of the enemies the terrain tracker dosent snap to both of them only to one of them and it gets all confused Ill try to make a new .cap that illustrates the problem better but Im at work now...

  • What do your containers look like? Is TerrainTracker in the same container as GroundCollision? Or are those families, not objects? It's kind of hard to tell exactly how things are set up from your screenshot.

    Also, reverse the order of your For Each and X Greater Than events. It should look like this:

    +For each Ground
       +Ground X Greater than PlayerSprite.X
          ->Ground: Set 'Facing' to -1
          ->TerrainTracker: Set position blah blah
       +Ground X Less than PlayerSprite.X
          ->Ground: Set 'Facing' to 1
          ->TerrainTracker: Set position to blah blah[/code:29u6a9ks]
    
    That way you only need one loop.  And get rid of the Always under your For Each, it's not necessary because the loop will run every tick regardless.
    
    Final question: were you able to get the AI working for one object without families?  Just to make sure it worked in the first place.  If not, give that a test first.  And if you can't get it to run, try posting a .cap so someone can take a look.
  • I know it works with one enemy but when I make another instance of the same enemy it gets confused. I got rid of the collision thing for now cause its just making things messy I can add it in once I get the terrain tracker working.

    The terrain tracker is contained in the enemy. And I have two instances of the enemy on the field. Two terrain trackers are made but they are both placed at one enemy...

    And I cant post the Cap cause the guy Im working with dosent want our Ideas stolen... He has had that problem before...

    *edit

    Ha it was the for each setting of the terrain tracker that was messing with it...

    but now if one terrain tracker overlaps an object with the terrain attribute they all jump...

    and if I add a for each ground object it crashes...

  • Okay, so you got your TerrainTrackers lining up with your Ground objects correctly? All right then...

    but now if one terrain tracker overlaps an object with the terrain attribute they all jump...

    and if I add a for each ground object it crashes...

    Hmm... try adding the "jump" action to the main For Each loop, like so:

    +For each Ground
       +Ground X Greater than PlayerSprite.X
          ->Ground: Set 'Facing' to -1
          ->TerrainTracker: Set position blah blah
       +Ground X Less than PlayerSprite.X
          ->Ground: Set 'Facing' to 1
          ->TerrainTracker: Set position to blah blah
       +Ground Platform: Is on ground
       +TerrainTracker overlaps Terrain
          -> Ground Platform: Jump[/code:oiw5hk3w]
    
    The reason I included "+Ground Platform: Is on ground" is so it picks the proper instance of Ground, even though it should be doing that anyway with the For each loop.  I did have some trouble keeping track of picked objects in my AI so you might need to remind Construct which Ground you're talking about.  Theoretically picking TerrainTracker by itself should also pick the proper instance of Ground to go with it though, so test it without that at first and see if it works.
    
    (Note for the devs:  I haven't had a chance to do any testing yet on the loops and picking problem.  It might not be a problem at all, just bad code on my part.  It's on my list of bugs to check out though, I'll get to it eventually.)
    
    Oh, and if you still can't get it working, PM me the .cap.  Tell your friend I won't steal it.
    
    Edit:
    You do know that setting it up this way will make all your enemies jump the moment they hit the ground, right?  They'll be bouncing like rubber balls all over the place.  If that's the effect you're going for, that's cool, just a heads up.
  • Are you using the latest build? Can you reproduce this in a blank .cap file? It's hard to see the setup of containers, families, movements and family movements from just the event sheet listing - it'd be very helpful if you can reproduce.

  • Im in class now finishing up a project Ill get a new cap ASAP.

    Side note

    I hate Power point with a passion right now.

  • Deadeye: Im going to PM the Cap to you sorry for the messy code Ive been learning as i do this getting better as I go... Its under the event sheet Ground AI

    Ashley: Ill try to get a Cap to you as soon as you can but I just got slammed with end of semester assignments.

  • I just got slammed with end of semester assignments.

    Tell me about it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I could pm what I have now if you want a look its in a separate event sheet but other than that it might take a week... and its pretty easy to tell what enemy is the one Im testing... Also I only have 2 ground enemies but it made 3 terrain trackers....

    At least we have winter break to look forward to in a week or two Right!

  • Check your PM's, I fixed your jump.

    It seems that Containers and Families aren't communicating properly somewhere, I had to pick instances by object instead of by family. When you try to recreate your bug for Ashley, focus on that.

    Also, I changed some things around and made some notes for you. It's all in the comments.

    And something I did made it so that the regular preview runs now too, it doesn't just run in debug any more. I have no idea what it was though.

    One piece of advice: I know that organization is a good thing, and I admire your tenacity with naming everything properly, but you've taken it to extremes. You have one layout and fifteen event sheets. At least three of those are for player actions. I think you might just be making more work for yourself there... most (if not all) of your player controls should be under just one event sheet, if only so that you can access them more easily. It'll be harder to keep track of how actions interact if you have your them spread across so many event sheets.

    Also I only have 2 ground enemies but it made 3 terrain trackers....

    You should make sure you have an equal number of enemies and trackers in your layout, since they're contained together. I created a second tracker for your second enemy and it seems to have sorted out.

    Or, do like I did and check "Destroy on startup" for all of the contained objects that go along with your enemy, then use spawners to create your enemies at runtime.

    In fact, I'd go so far as to say you should probably look into making a level editor/loader for this game. It seems that you want to make something big here. Once you get your engine down, concentrate on making a level editor instead of placing all of your stuff in the layout. It'll keep things lean when it comes to the final build.

  • [quote:dsjjup4m]

    One piece of advice: I know that organization is a good thing, and I admire your tenacity with naming everything properly, but you've taken it to extremes. You have one layout and fifteen event sheets. At least three of those are for player actions

    Thanks Yeah... I know I went over board with the event sheets Its easier for me to see what one does when it is Isolated. It just makes it esier for me to find. I will eventually go in and cut down the amount we have, but every time I have to implement something new I put it in a sheet and then I test it till it works then just for get about it I know it seems messy but it makes it easier for me to see whats goin on in the sheet with less events on the screen. I need to clean it up and go back a redo something that would be done better with fewer events. This is my first project in construct and I was really just learning it in the beginning now that I know more I will hopefully be able to program it better.

    [quote:dsjjup4m]Or, do like I did and check "Destroy on startup" for all of the contained objects that go along with your enemy, then use spawners to create your enemies at runtime.

    Good Idea I was going to implement this after I got the jumping working...

    [quote:dsjjup4m] In fact, I'd go so far as to say you should probably look into making a level editor/loader for this game. It seems that you want to make something big here. Once you get your engine down, concentrate on making a level editor instead of placing all of your stuff in the layout. It'll keep things lean when it comes to the final build.

    We want to do this but I dont really have any Idea on how to make a level builder.

    Thank you so much I will defiantly take your advice and clean up the code...

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