# 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.x = 0;
rotation.z = 0;
rotation += bankAxis * bank;
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

``````#if ANNOTATE_LOCALSPACE

``````

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.