### Random 4-ways movement AI

#### Nobunage

• Posts: 2
Hi, I started a game recently, a survival thing with "zombie like" creature, and i want them to move around the scene without goal, but when they are at a certain distance to me, try to reach me and attack me ( or eat)...

I tried to adapt some plat-former 2 ways movement behavior to this but without success, if anyone have an idea, write it please

#### chaosoul

• Posts: 260
I might upgrade my old random ai walking behavior to this. I can make them walk randomly but the whole part about attacking I won't be making sorry.
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

#### Nobunage

• Posts: 2
sure no problem, even just the random movement is really appreciated !!!!

#### chaosoul

• Posts: 260
I probably update on sunday.
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

#### thegenericbanana

• Posts: 494
There's already a behavior for this-Random Movement, on the forge, by kapu.

If they're close, do:
Make 2 game attributes-Y and X. Make a behavior for the player, in which it always sets x (game attribute) to x of self, y (game attribute) to y of self.

Then, for the enemy-
If y of self<y+20 and y of self>y-20 and x of self<x+20 and x of self>x-20
(Do whatever you want)

That should work. Note you can change the 20s, they just make it so if the player is in that area of the enemy, it does that. More (40, 60, etc.) makes it so the area is bigger, while less, like 10, makes the area smaller.
Johnny Turbo's Surgery Frenzy