I am making a Jet game, and at the moment the jet can go from 0-500mph now I need it so the faster I am going the slower the yawspeed is and the slower I am going the faster the yawspeed. But I cannot figure out get a suitable value based upon speed.
so something like this, without having to write if speed < 500 speed > 450 for each yawspeed
500 speed 1 yawspeed
450 speed 2 yawspeed
400 speed 3 yawspeed
Here’s my code
// set the max yaw speed
var defaultyawspeed :float = 20;
function Update() {
//prevent going faster or slower than 0-20
if (defaultyawspeed < 0){
defaultyawspeed += 1;
}
if (defaultyawspeed > 20){
defaultyawspeed -= 1;
}
// yaw left and right pitch up and down with mouse
function FixedUpdate() {
var h = Input.GetAxis("Mouse X");
var v = Input.GetAxis("Mouse Y");
transform.Rotate(0, v * defaultyawspeed,0);
transform.Rotate(Vector3.right, h * defaultyawspeed);
}
}
// acceleration and deacceleration over time
function brakespeedlogic () {
speed -= brakespeed;
defaultyawspeed += 1;
}
function logic () {
if (speed < maxSpeed) {
speed += 1;
defaultyawspeed -=1;
}
}