UnitySteer to apply banking in a turn

Ok so now i have Unitysteer and AngryAnt Path working together to get my ship around the track perfectly. I have been trying to figure out how to get my ship to "bank" around corners. I have a flight control script attached to my player's ship that applies all of the necessary forces to get my ship to fly and turn while banking appropriately. it uses this block to create the banking effect:

//need to figure out a better variable to watch for instead of angularVelocity
float amountToBank = rigidbody.angularVelocity.y * bankAmount;

bank = Mathf.Lerp(bank, amountToBank, bankSpeed);

Vector3 rotation = transform.rotation.eulerAngles;

rotation *= Mathf.Deg2Rad;
rotation.x = 0;
rotation.z = 0;
rotation += bankAxis * bank;
rotation *= Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(rotation);

I tried to implement this into the "simplevehicle" class but was unable to get it to work properly. I also noticed the function "public void regenerateLocalSpaceForBanking (Vector3 newVelocity, float elapsedTime)" but that would only rotate my ship straight up and down. I tried to change up the vectors but that didn't effect anything. I know that unitysteer is not using "Forces" to provide the steering at this point so i am not sure that I am attacking this problem correctly. Any pointers on where/how I should go about fixing this would be greatly appreciated.

regenerateLocalSpaceForBanking is one of Craig Reynolds' original functions, used only on the Boid behavior. It was intended to have the boid bank as it turned, but as Reynolds himself mentions in the comments, it's a no-basis-in-reality "banking" behavior.

It basically:

  1. Calculates a banking vector based on the current acceleration and an arbitrary up vector.
  2. Blends it into the vehicle's current up vector at a fixed, arbitrary smoothing rate.

If you'd like to visualize what it's doing, replace the lines within


with some Debug.DrawLines and you'll get a better idea of the adjustment.

Again, this is only used for the boids, so if your vehicle is one that is supposed to be grounded, it likely will not help you.

Adding separate answers as this is a multi-part question.

I assumed that you were just doing a type of animation instead of applying forces to have the physics engine do the work.

I see what you mean now. Yes, that is correct - UnitySteer is not pushing the object around with the physics engine but instead altering its position. It is however calculating forces to apply to the direction, blending them and applying them, which is what threw me off (I meant your "at this point" to mean at this point in the vehicle calculations flow).

A good example would be the Boid vehicle. You'll see that function mixes the calculation of the forces necessary for separation, alignment and cohesion. If you were to do a flocking, banking vehicle you'd add your banking vector in there.