Unity: Creating Simple Wander AI Behaviour

Following up on our previous post about employing a Navmesh to simulate basic crowd behaviour, here’s a pretty easy way to script some random movement to give you a basic “Wander AI” behaviour for your game objects that you can use for for your 2D or 3D projects. This is a quick, no frills tutorial that shows you how to start with a simple 3D game object and attach some very basic AI to it with the end result being a game object wandering around your scene. This is ideal for NPCs, non interactive characters, or zombies (because you know, zombies). The choice is yours!

As an example, you can follow the aformentioned Crowd Behaviour tutorial and instead of using a waypoint for your agent destinations, you can also follow TRGameDev‘s WanderAI tutorial and attach the wander script to the agent game object. So now, instead of having a group of agents all moving towards a defined destination/waypoint, they will simply wander around aimlessly, which is exactly what we want in this scenario. This is a very simple solution that you can use to build upon in your game using more complex characters and scenes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.