Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: bonsaisushi on May 29, 2017, 05:23:30 PM

Title: Simple Wandering AI
Post by: bonsaisushi on May 29, 2017, 05:23:30 PM
Hello everyone!
I'm currently looking for a wandering script for a 3d object, it just needs to move on X, Z (left and right, not upwards) inside a defined area (navMesh is okay)

I tried some tutorials on YouTube but none of them worked fine, does anyone know how to do something like this?
It just needs to move around randomly
Title: Re: Simple Wandering AI
Post by: tcmeric on May 29, 2017, 09:55:55 PM
I have a tutorial about generating random numbers between a specific range:
You can generate a random x/z for the navmesh, that is within your playarea. (See my tutorial which shows you how to figure out the area).

Then use these numbers to make a vector3 for the navmesh. Use the "set agent destination". Then once you have arrived at the destination (get agent remaining distance, then compare it to 0 to know when you have arrived), you can generate the next x/z for the next position.