Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
Sometimes we play with AI's that looks smart, how are they doing it?. I'll give you a reason to believe in automated steering behaviours for your next game AI.
AI's just wanna be AI's?
In a land full of chars walking placidly, hunting you or just guarding a door while patrolling, there is this question in the air: "What is this entity thinking ?".
I was always fascinated with this kind of question, and I loved how some AAA games AI's were able to avoid obstacles, find and reach your position while dodging bullets without any trouble. So I began to learn everything about complex AI's: movement, behaviours, training, etc. My AI's must want to be more than a simple zombie bumping into or hitting walls!
- That is what I thought -
It is the way an entity decides how to move in the space, how to interact with you and other game elements. In short; how to live in your world! The first conceptual picture of this that appears in my mind is the Non Player Characters from the Sims. They sure have a really complex behaviour tree. If you want to know more about this, check "Behavior trees for AI: How they work".
Sometimes a char AI can't be plugged and start working, you need to train it, and you have software like ORTS to do such things, this is used to create a balance between player skill and the game entities, for example for strategy or tower defense games. You also can use genetic programming to evolve AI's to what you really want like this genetics cars based in Box2DCar.
All this stuff is great, but for my animal-herding game I needed something different. The first prototype I made last year only used a simple approximation behaviour: each lamb has a target node, they follow it using a simple force vector while they are waiting for the dog to scare them, and once scared they just change the target. As you can see in the video, they are not seeing each other, they dont act like a flock as I wanted. The research was just about to begin with this when the world opened in front of me and suddenly I found the exact thing I needed.
"Autonomous characters are a type of autonomous agent intended for use in computer animation and interactive media such as games and virtual reality. These agents represent a character in a story or game and have some ability to improvise their actions. This stands in contrast both to a character in an animated film, whose actions are scripted in advance, and to an "avatar" in a game or virtual reality, whose actions are directed in real time by a human player or participant. In games, autonomous characters are sometimes called non-player characters.
An autonomous character must combine aspects of an autonomous robot with some skills of a human actor in improvisational theater. These characters are usually not real robots, and are certainly not human actors, but share some properties of each."
Steering Behaviours by Craig W. Reynolds, this is the real thing,and it can manage flocks! (well, it can manage whatever you want, even just a simple entity with different behaviours)
You can use Steering Behaviours for:
A racing game AI: automated vehicles following the road, or ships that follow a leader
Any game that uses navigation AI: rpg npcs, action game chars: A* and Pathfollowing Steering Behavior
A game with AI behaviours needs: flock, wander, flee, pursuit and evade, seek, etc
Steering behaviours can be very cheap for cpu usage, so you can integrate it without worries in mobile games.
I implemented my first version of Steering Behaviours for moving enemies
In the game The Legend Of Kuzu, this was only a flocking with avoiding collisions and simple seeking.
This is a steering behaviour from a global vision/view
Based on OpenSteer framework.
Each behaviour is represented as a force vector. Giving more importance to one or another by making the vector scale bigger, makes the entity move in the direction of this force-behaviour. For example, set the player as a seeker so you can have the entity char follow a position and then add an entity that is a sheep that will evade wolves entities. Now set an evade force for the sheep and a pursue force for the wolves, you may want to add a wander force to make the sheep follow a location, then you will have a diagram like this:
you can download this sample from the ShiVa wiki page: ShiVa Steering.
Why did I choose ShiVa engine? - you can code in Lua and export the game in C++, it is so efficient that I can run complex behaviours with more than 15 entities in an low-spec device with a good framerate.
Well, in this example, we are updating the target location for the player entity, which is a seeker, with each mouse event. Therefore, the most important force for this entity is the seek function. We use the physics engine and a sphere collider as the dynamics base.
The fleeing entities watch for a place away from pursuers using rays. So the function evade is the most important (greater vector scale magnitude) for these (also they are not using seek but wander). The pursuers, are trying to reach the targets entities.
A more elaborated example with chars, animations, sfx and some art:
First you get the translation of the entity, then compute vectors and directions to get the next force vector. Check if distance is greater than radius, normalize and scale the vectors and set the new velocity in the scale limit for each entity.
Once you sum all the forces and set the new speed, the character will follow the according behaviour of movement.
If you want to know more check :
Have fun with steering behaviours.
Special thanks to Eric Barth for his help with translation and edition.
Read more about:
Featured BlogsYou May Also Like