Want to see UnitySteer in action? We’re using it for our own game, click here for a preview.
After a few months of polish, I’ve allowed version 2.1 of UnitySteer to escape (which is to say I’ve merged the code that has been live this whole time into master, and won’t be altering its behavior for a few months). You can find it on GitHub, and as usual can press that nice Downloads button there to get a zipped version of the release.
I’ve yet to update UnitySteerExamples, as I’m rather tied up. That’ll have to wait until a later date.
I’ve detailed most of the path following changes on a previous post. I recommend you go over it, as it details the use and rationale behind the new SteerForPathSimplified and other classes.
AutonomousVehicle and Vehicle changes
I’ve extracted several values that were originally constants to a property you can configure. When introducing a new configurable value, I’ve aimed to keep the same behavior as before by defaulting it to the previous constant, but as usual please commit your code and test thoroughly.
POSSIBLY BREAKING CHANGE: Added ArrivalRadius to Vehicle, to separate the concept of the vehicle’s volume/area from when it’s close enough to its target. The previous behavior could have considered arrival when the target point was within the vehicle’s radius, but in some cases you don’t want the vehicle to just be touching the point, but to be within a certain minimum distance. You can use ArrivalRadius to specify this arrival value.
AutonomousVehicle now allows you to disable the acceleration blending. Simply set AutonomousVehicle’s AccelerationSmoothRate to 0, or change to any value between 0 and 1 to configure the blending rate you need.
Vehicle.GetSeekVector previously always considered the Vehicle’s current speed in his calculations to the point, to create an arrival effect where the vehicle slowing down when closer to its target. This had the side effect that if you were using GetSeekVector to follow a series of points, the vehicle would look like it was accelerating and decelerating all the time. I’ve added considerVelocity as a parameter, which if set to false will allow you to tell it to skip the arrival calculation. The default is still the same behavior as before.
Added VehicleLookAtOverride behavior. The previous change had the side effect that a vehicle could approach its target too fast at a bad angle, and go into a circle like a car spinning in place. VehicleLookAtOverride will allow you to override the blending value on the vehicle, to turn the transform towards the point the vehicle would have been led by the raw, unclipped force being applied (before MaxSpeed and MaxForce are considered).
Zeroing the Y force for planar vehicles before the force and speed even get clamped. This may have an effect on your previously created vehicles, but it shouldn’t alter their behavior significantly. I’d rather not do these sort of changes after release, but the alternative was forking AutonomousVehicle.
AutonomousVehicle now takes into account its CanMove value. If CanMove is FALSE, the forces are still calculated, but the vehicle does not update its position. If you want to avoid calculating the forces altogether simply disable the vehicle.
AutonomousVehicle no longer evaluating HasInertia, and will log an error on Start if it finds it to be true. All the steering behaviors I’ve created assume “Star Wars physics” for their calculations, where if you stop applying a force to the object it should stop. This means that HasInertia should be false. No longer evaluating the value on AutonomousVehicle to avoid the confusion caused by the vehicle not acting as expected, and added a warning on vehicle start. If for any reason you have an agent using AutonomousVehicle that depends on inertia, you’ll need to modify this class manually.
Added OnArrival to Steering. Now every steering behavior will raise an OnArrival message when it would first stop moving (if on its previous evaluation it had returned a force, and on this one it no longer does so, meaning the behavior considers it has arrived at its destination). To use, simply assign the OnArrival delegate of your Steering behaviors:
_steerForPath.OnArrival = OnArrival;
protected void OnArrival(SteeringEvent<Vehicle> message)
// Do Something
Any receiver of an OnArrival call can now tell the vehicle to retry once by setting the SteeringEvent’s Action property to ‘retry’. This is useful if you don’t want the steering behavior to skip a beat when it has arrived at the designated spot and needs to await instructions from the receiver (as otherwise the value returned might get cached for a few frames).
- BUGFIX: Setting the Tick’s TickLapse will reset the next tick time. As it was previously, the behavior wouldn’t be ticked again until the time defined by the previous TickLapse value, something I noticed while having a behavior that changed the TickLapse when the agent was idling.
- Documented the actual state of SteerToFollowPath.
- Removed PolylinePathway. Use Vector3Pathway instead.
That’s it for now. Enjoy!