HI I mad this script for a tank:
var flWheelCollider:WheelCollider;
var frWheelCollider:WheelCollider;
var rlWheelCollider:WheelCollider;
var rrWheelCollider:WheelCollider;
var currentSpeed:float = 0.0;
var maxTorque=260.0;
var maxSpeed:float = 70.0;
var reversmaxSpeed:float=-70.0;
//---------------------------------------------------------------------------------------------------------------------------------------------------------
function FixedUpdate () {
flWheel();
frWheel();
rlWheel();
rrWheel();
currentSpeed=((flWheelCollider.radius*Mathf.PI*2)*flWheelCollider.rpm*60/1000);
currentSpeed=Mathf.Round(currentSpeed);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------
function flWheel(){
if (currentSpeed<maxSpeed¤tSpeed>reversmaxSpeed&Input.GetKey(KeyCode.F)){
flWheelCollider.motorTorque=maxTorque;
rlWheelCollider.motorTorque=maxTorque;
}
else {
flWheelCollider.motorTorque=0.0;
rlWheelCollider.motorTorque=0.0;
}
}
function frWheel(){
if(currentSpeed<maxSpeed¤tSpeed>reversmaxSpeed&Input.GetKey(KeyCode.H)){
frWheelCollider.motorTorque=maxTorque;
rrWheelCollider.motorTorque=maxTorque;
}
else {
frWheelCollider.motorTorque=0.0;
rrWheelCollider.motorTorque=0.0;
}
}
function rlWheel(){
if(currentSpeed<maxSpeed¤tSpeed>reversmaxSpeed&Input.GetKey(KeyCode.C)){
rlWheelCollider.motorTorque=-maxTorque;
flWheelCollider.motorTorque=-maxTorque;
}
else {
rlWheelCollider.motorTorque=0.0;
flWheelCollider.motorTorque=0.0;
}
}
function rrWheel(){
if(currentSpeed<maxSpeed¤tSpeed>reversmaxSpeed&Input.GetKey(KeyCode.B)){
rrWheelCollider.motorTorque=-maxTorque;
frWheelCollider.motorTorque=-maxTorque;
}
else {
rrWheelCollider.motorTorque=0.0;
frWheelCollider.motorTorque=0.0;
}
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------
My goal is:when I press"F" the the left track pushes forward
when I press"H" the the right track pushes forward
when I press"C" the the left track pushes back
when I press"B" the the right track pushes back
My problem is:when I press"F" nothing happens
when I press"H" nothing happens
when I press"C" the front and rear left Wheel Colliders pushes back
when I press "B"the front and rear right Wheel Colliders pushes back
If some one could look at this and PLEASE could help me,I would be wary grate full.
Thanks