UnitySteer – Steering components for Unity
Update: View Hairy Tales, one of our games using UnitySteer.
Update: We’ve released version 2.0 of UnitySteer. Go here to read about it or check out the new examples , as this article is now outdated.
Back in February I was working on a project for an article meant to appear in a GDC issue of Unity Developer. The article was intended to be a tutorial on pathfinding with several agents, and used Path for finding routes in the scene. Path, however, will only tell you how to best get from point A to point B, but will not maneuver your agent nor tell it what to do if it runs into other agents or stationary obstacles, so part of the article dealt with obstacle avoidance.
The tutorial got shelved when there were delays with Unity Developer and the issue was canceled, but the work I’d done on the implementation got me thinking about the need for an obstacle avoidance and steering library for Unity, so in late April I started doing just that. A good couple months later and with some help from Emil Johansen, we’re now ready to release UnitySteer.
What does it do? UnitySteer contains a series of classes that help your game characters or vehicles maneuver around a scene: how to accelerate and for how long, how to turn depending on vehicle characteristics, how to act when avoiding obstacles or neighbors, how to keep a distance from other agents, or many other cases. Some of these behaviors are quite simple, but they can easily be combined to generate more complex vehicles.
It builds upon OpenSteer and OpenSteerDotNet, but we have ported it completely to Unity, removing redundant classes and calling Unity methods wherever it’s appropriate. It has also been expanded so that the vehicle classes have an option for receiving a Transform or Rigidbody on initialization, which the vehicles can then affect directly, and has undergone refactoring on areas such as pathways.
During the port we have also expanded on the original vehicle examples, generalizing them when possible, and have added other functionality such as:
- Vehicle tethering
- Radar prefab for a trigger-based proximity detector
- Prioritization of steering behaviors based on weighing
- Integration with AngryAnt’s Path
We currently have vehicles (along with their MonoBehaviours) for:
- Flocking
- Obstacle avoidance
- Wandering
- Pursuit
- Chains of vehicles
All provide support for 2D and 3D movement.
You’ll notice that the base vehicles are C# classes and not MonoBehaviours. We did it this way for several reasons, including:
- It allows us to use the vehicles to animate particles, which have neither a transform nor a rigidbody of their own.
- Standalone classes are more lightweight, and we get to control when their Update methods are called, so we had the flexibility of doing multi-vehicle updates (you’ll see what I mean on the Lightning example).
Here are some webplayers of the library in action (they require the Unity 2.5.1 plugin):
- Obligatory boid example
- Obstacle avoidance
- Lightning bold built with particles, pursuing a wandering object
You can also see some Quicktime videos:
- How obstacle avoidance works behind the scenes (2.5mb)
- Path following with basic neighbor avoidance (67mb)
During the coming days I’ll provide examples of the classes plus notes on how to use the library. It is still a work in progress, so things are bound to be changed or expanded as we go. For now, you can obtain the steering classes on github, as well as an example project using them. If you are unfamiliar with git you can obtain a copy of the project here, but I do recommend getting acquainted with git, since the repository will be updated more often.
UnitySteer is released under the MIT license.











Do you know that many classes are not compiled with unity?
Namespace are just fine, but with code compiled by Unity, the class name must match the filename. Same goes with Generic classes.
So generally you have to also declare a shell class outside of the namespace that matches the filename.
Geetings Heinz
Hi Ricardo,
I am trying to get the example project working and it can’t find all of the scripts that are present in the assets folder.
I have Unity 2.5.1 I updated the mono code when I installed Path. I am running OSX 10.5.7.
I believe I have missed something simple?
Thanks
Trev
Great work! I just wonder if it works on unity iphone?
It does, but of course you’ll have to scale the number of agents to deal with the reduced platform power, and might not want to rely as much on the physics engine for proximity detection.
Hello,
I would use for A.I. UnitySteer a car but not how. I built a city with Unity, I created a network of roads by A * Pathfinding and my idea is that cars can detect potential obstacles (other cars, traffic signs, pedestrians, etc..), but not how to apply my UnitySteer project.
I searched for tutorials on its operation and applications, but I still know how to apply it on my project, to see if I could help.
Thanks,
Pedro.
Hello Pedro,
For path following you would use SteerForPathSimplified. You can use SteerForNeighborAvoidance to avoid other cars, although I haven’t tested it un a constrained corridor like a road. Traffic signs, pedestrians and others you would end up creating the behavior for, likely via a behavior tree.
You can read some of the discussions here:
http://www.arges-systems.com/articles/213/unitysteer-upcoming-path-following-changes/
http://www.arges-systems.com/articles/234/unitysteer-2-1-released/
John asked a similar question on the latter link.
Hi,
I have found a bug in Steer for tether behauviour when it combines with Wander and Neighbour avoidance behaviours. When attached object reaches the maximum distance and tether starts its force, the object gets stuck, with no movement. This is caused by small numbers in velocities, which are zeroed by blendIntoAccumulator in AutonomousVehicle. I have resolved by applied a threshold to avoid applying tether force when the vehicle has low velocity, in CalculateForce from tether:
if (distance > _maximumDistance & Vehicle.Speed > _speedThresholdToApply )
{
steering = difference – Vehicle.Velocity;
}
Best regards and excellent job!
Hello Ricard,
Thanks for the pointer. I believe another change I did on the experimental branch has a similar effect, but it was a while ago so I’ll verify it. Cheers!
Hello. I’m new to this UnitySteering, and thought it’d be nice to ask if there is a tutorial anywhere for UnitySteer.
Hello Isaac,
I’m afraid there are no recent tutorials, as I have been swamped with our game. Depend on your use case (for instance, if you’re using bipeds) you may want to wait for the RVO/PLE implementation in Unity 3.5.