Monster AI System?

I need a zombie AI system that has my zombie move towards the player if close, and be able to jump if needed.
I have the zombie move in one direction, but I need it to be able to move in both directions.
Thanks!

3 Likes

first question before I make code that should work, what’s the game style, you mentioning jump I assume left to right like my games and the tutorials and Mario, but I need to know this before I can help.

Just so you know these games are known as Platformer Games.

Also @Truce2017 you could make 2 raycasts pointing left and right and if one of those raycasts hits the player then the zombie goes in that direction. I would screenshot the code for this but my school blocked flowlab

1 Like

If your doing a platformer, theres a tutorial video on enemies like that.

I had an idea but the zombie can’t jump.
Here is the code:


The raycasts check to hit the player, and if it does, it moves in that direction.
If none do, it stands still.
But I also need the zombie to be able to jump up a block if the player is on high ground.

2 Likes

There are a few things you could try, you could add another ray cast which is shorter for blocks Infront of them giving off a jump, or you could find some other way because the monster might be stuck jumping if infront of a block. Also I recommend a wandering zombie.

I would make an example to make a better version but as of right now I have no access to Flowlab.

OK,
I’ll try again with a different code.
Coding is very strict.

1 Like

To do this make the same thing as the player raycast check but replace the raycasts checking for the player with “any” and use a XOR to exclude any entities. Then make the number make the zombie jump.

Ok, I’ll try it!
(20charaters)

1 Like

For the 20 characters you can make this:
< sdfklghsdfgkjhdsfglkshdfg > but with no spaces. This works because the forums thinks it is an embedded link (I think) and makes it invisible

oh, ok thats cool!

1 Like

You kinda messed it up, there should be no spaces in-between the “<” and the “>” I added in the spaces for an example. Also it doesn’t have to be exactly the same as mine you can put anything between the “<” and the “>”.

OK

1 Like

Here I’m not sure if this helps, but its from @hihilogic

If you want it to follow it for a certain distance change this;

1 Like

This is very useful!
Thanks!

1 Like