Trying to create smart AI for platformer game

For questions about using Classic.

Post » Mon Feb 21, 2011 4:05 am

I've done a smart form of AI for a game, but I'm having a problem getting multiple enemies to work properly. One enemy alone works fine, but I want separate enemies to each chase the player if they can see him. Can anyone help me get an enemy to attack when there's more than one on the layout?

I'd like for an enemy to see the player and attack without making all of them attack. If it's possible with the way I set it up, could someone tell me how?

http://www.mediafire.com/?ibqwh9djubwjbg3

Note: This is called a tutorial because I planned to make a tutorial with this until I discovered this bug. If someone can help me fix this, I'll finish the tutorial and release it as soon as I can, unless there's already something like this that I missed in a search.
B
2
G
1
Posts: 22
Reputation: 494

Post » Mon Feb 21, 2011 11:53 am

Doing it with the "Group Enable" method doesn't pick, and is buggy. Generally, stay away from disabling and enabling groups in events, it's buggy. I just put all your existing events under the LOS condition, and it works fine.

http://dl.dropbox.com/u/1378330/AI%20Tu ... 20EDIT.cap
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Mon Feb 21, 2011 1:48 pm

I didn't know that. Coming from MMF2, so I'm used to using groups for a lot of things. I forgot you could add events under other events like that in Construct. The chasing is a little odd since they stop chasing at random times, like if you run through them, but I guess that's something in my events.

Thanks for your help. If you could hint me as to what's causing the random stopping, that would be great. I'm hoping to make it simple for everyone to follow, but I don't know how reasonable that is.
B
2
G
1
Posts: 22
Reputation: 494

Post » Tue Feb 22, 2011 3:04 am

The LOS object doesn't like it when you collide. You can probably fake it pretty darn well. Just make a PV for the enemies, and always set it to the distance between the main character and it. When the value drops below a certain limit (i.e. the character gets close), enable the chase behaviour. This is faster than LOS, but doesn't deal with enemies not being able to see through solids.

If you want to keep the LOS, you could implement both systems. Make the LOS enable the chase behaviour, but also make it so when the player is very close, the behaviour is also on. This should solve the stopping when your are overlapping the enemy.
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Tue Feb 22, 2011 3:09 am

Oddly enough, it fixed itself once I changed the sprites. I'm assuming it had something to do with hot spots or something. I'll look at it later and find out for sure.
B
2
G
1
Posts: 22
Reputation: 494


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests