Trouble with Families and AI

For questions about using Classic.

Post » Thu Dec 04, 2008 1:36 pm

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 [url:13onshwc]http://www.scirra.com/phpBB3/viewtopic.php?f=4&t=1949&start=60[/url:13onshwc] 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...
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Thu Dec 04, 2008 2:42 pm

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:

[code:29u6a9ks]+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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Dec 04, 2008 3:21 pm

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...
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Thu Dec 04, 2008 3:50 pm

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

[quote="Aeal5566":oiw5hk3w]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...[/quote:oiw5hk3w]

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

[code:oiw5hk3w]+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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Dec 04, 2008 4:03 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,590

Post » Thu Dec 04, 2008 5:05 pm

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.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Dec 05, 2008 1:28 am

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.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Dec 05, 2008 2:01 am

[quote="Aeal5566":nxtgz9fl]I just got slammed with end of semester assignments.[/quote:nxtgz9fl]
Tell me about it :?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,590

Post » Fri Dec 05, 2008 2:23 am

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!
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Dec 05, 2008 7:15 pm

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.

[quote="Aeal5566":3ty5zda9]Also I only have 2 ground enemies but it made 3 terrain trackers....[/quote:3ty5zda9]

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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: GameOverBeast and 1 guest