Platformer Zombie AI [need help :P]

Get help using Construct 2

Post » Tue Aug 21, 2012 12:07 pm

Hey guys. I have some problem with making Zombie AI.

For make them move and fall I use Platformer behavior (Default controls: no).
And their movement look like that:

zombie.x < player.x - simulate control Right
zombie.x > player.x - simulate control Left

Also, they need to detect boxes and jump over it
(if Speed = 0 - [idling] - simulate control Jump)

But if there will be 2 boxes and one of them will on top of other and zombie needs to destroy first, and then jump over second.
I tryed to make some kind of detector (sprite with bullet behavior) and it works kinda fine but i'm think there is a way to make it easier.

Want to see your suggestions :)

Vladoss2012-08-23 13:49:00
B
38
S
15
G
6
Posts: 238
Reputation: 7,760

Post » Tue Aug 21, 2012 4:43 pm

That's a good one!

I would have it so that a box detects if there is another one on top of it(There are several ways to do this) and if it does, it creates an invisible box that extends past both sides of the visible box. If a zombie is overlapping with the invisible box, have it skip the jump script and activate an attack script. When the box is destroyed, destroy the invisible one too.
B
5
Posts: 7
Reputation: 528

Post » Tue Aug 21, 2012 4:45 pm

You'll want a couple of detector sprites at different heights attached to the zombie. No need to make them bullets.

EDIT: Previous suggestion made while I was typing will probably work too ;)sqiddster2012-08-21 16:46:10
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Aug 21, 2012 5:09 pm

Okay, couple of detector sprites. But there will be alot of zombies. How to make specific detector follow specific zombie?

I was trying to make it using private variable in detector (set it to zombie UID):

Start of layout ->
+ For each zombie - create object detector at zombie.x, zombie.y
                             - set detector.a = zombie.UID
Every tick ->
+ For each detector
   + detector overlapping zombie
   + detector.a = zombie.UID - set detector position to zombie.x zombie.y

but when zombie overlapping other zombie detector's position goes wrong and I'm again start to generate thoughts like: there is another way to make it easier.

Vladoss2012-08-21 17:09:52
B
38
S
15
G
6
Posts: 238
Reputation: 7,760

Post » Tue Aug 21, 2012 5:27 pm

You luck day: http://www.scirra.com/tutorials/361/understanding-uid-iid-health-of-enemies-and-rocket-smoke-trail

http://www.scirra.com/tutorials/355/making-character-composed-of-multiple-parts
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,211
Reputation: 18,473

Post » Wed Aug 22, 2012 12:17 pm

Thank you all!Vladoss2012-08-23 16:18:54
B
38
S
15
G
6
Posts: 238
Reputation: 7,760


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, gregorysforster, onzephyr and 2 guests