I need a simple AI script to make a zombie object ‘walk’ around randomly. I’ve googled and googled but all I can find is stuff on the mathematics function ‘Random Walk’. Maybe it’s related?
I’m using my own JavaScript 2D engine and I need to have something like:
function update() {
//Move using available physics engine stuff:
// this.position, this.rotation, this.velocity, this.torque, this.acceleration
// this.torqueAcceleration, this.drag, this.torqueDrag
}
Thanks! 🙂
I did do a similar script in C# XNA 2 years ago.
The logic is simple. Let’s talk about the logic of walking one zombie in pseudo-code:
The following is the walkable space / platform for the zombie:
If the position is more than half the walkable space, zombie face left. Otherwise zombie face right.
Pick a random distance to move between 5 to the end of the walkable space.
This should help you to create your script for all the zombies to roam around the map aimlessly. You can vary the values I’ve written in the pseudo-code to suit your game.