- Home /
Banking and momentum
Hi. I recently got a script for an aeroplane, and I need to know how to make it bank.
var maxTorque : float = 10.0f; var forwardForce : float = 10.0f;
var currentTorqueHor : float = 0.0f; var currentTorqueVer : float = 0.0f;
function Update() { currentTorqueHor = maxTorque Input.GetAxis("Horizontal"); currentTorqueVer = maxTorque Input.GetAxis("Vertical"); }
function FixedUpdate() {
rigidbody.AddForce(transform.forward * forwardForce); rigidbody.AddRelativeTorque(currentTorqueVer, 0.0f, -currentTorqueHor); }
This script doesn't let me bank. When I rotate a bit I have to go up to move in that direction. I've seen people do it before and it works very well. Also, I have a problem with momentum. When I change direction, it takes a while for my momentum to recede. So, if I turn the opposite direction, I will fly in backwards while slowing down until it stops, and then accelerate forward. Anyone know how to change this?
Answer by creative72 · Apr 09, 2011 at 11:18 PM
//replace with this script. //under edit-projectsettings-inputs set the axis you want // to use to bank and call it "Bank" . var maxTorque : float = 10.0f; var forwardForce : float = 10.0f;
var currentTorqueHor : float = 0.0f; var currentTorqueVer : float = 0.0f; var currentTorqueBank : float = 0.0f;
function Update() { currentTorqueHor = maxTorque Input.GetAxis("Horizontal"); currentTorqueVer = maxTorque Input.GetAxis("Vertical"); currentTorqueBank = maxTorque * Input.GetAxis("Bank"); }
function FixedUpdate() {
rigidbody.AddForce(transform.forward * forwardForce); rigidbody.AddRelativeTorque(currentTorqueVer,currentTorqueBank, -currentTorqueHor); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613121711im_/https://answers.unity.com/themes/thub/images/avi.jpg)