Page 1 of 1

Platformer Zombie AI [need help :P]

PostPosted: Tue Aug 21, 2012 12:07 pm
by Waltan
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

Re: Platformer Zombie AI [need help :P]

PostPosted: Tue Aug 21, 2012 4:43 pm
by Acrolith
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.

Re: Platformer Zombie AI [need help :P]

PostPosted: Tue Aug 21, 2012 4:45 pm
by sqiddster
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

Re: Platformer Zombie AI [need help :P]

PostPosted: Tue Aug 21, 2012 5:09 pm
by Waltan
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

Re: Platformer Zombie AI [need help :P]

PostPosted: Tue Aug 21, 2012 5:27 pm
by TELLES0808
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

Re: Platformer Zombie AI [need help :P]

PostPosted: Wed Aug 22, 2012 12:17 pm
by Waltan
Thank you all!Vladoss2012-08-23 16:18:54