Hi folks, i use the below script to control my ship, but instead of rotating the ship when on if(Input.GetAxis(“Horizontal”), i want my ship to strafe instead.
Thank you.
var flyingSpeed = 500;
var minThrust = 20;
var maxThrust = 300;
var Accel = maxThrust / 4;
//var Jumpspeed = maxThrust *5;
var turnSpeed = 100;
static var score : int = 0;
function FixedUpdate() {
if(Input.GetButton("Jump")){
flyingSpeed = flyingSpeed+maxThrust;
if(flyingSpeed>2000)
{
flyingSpeed= flyingSpeed-500;
}
}
if(!Input.GetButton("Jump"))
{
flyingSpeed = Accel + Mathf.Clamp(flyingSpeed, minThrust, maxThrust + Accel);
}
//Quando for necessario habilitar o Q para reduzir a velocidade
/*if (Input.GetButton("Q")){
flyingSpeed = Accel + Mathf.Clamp(flyingSpeed--, minThrust -Accel, maxThrust);
//flyingSpeed = flyingSpeed - maxThrust;
}
/*if(!Input.GetButton("Q"))
}
flyingSpeed=500;
}
*/
if(("Jump"))
{
rigidbody.velocity = transform.forward * Time.deltaTime * flyingSpeed; //Apply velocity in Update()
}
if(Input.GetAxis("Horizontal") > 0.0){ //if the right arrow is pressed
transform.Rotate(0.0, turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //and then turn the plane
}
if(Input.GetAxis("Horizontal") < 0.0){ //if the left arrow is pressed
transform.Rotate(0.0, -turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //The X-rotation turns the plane - the Z-rotation tilts it
}
if(Input.GetAxis("Vertical") > 0.0){ //if the up arrow is pressed
transform.Rotate(50.0 * Time.deltaTime, 0.0, 0.0);
}
if(Input.GetAxis("Vertical") < 0.0){ //if the down arrow is pressed
transform.Rotate(-50.0 * Time.deltaTime, 0.0, 0.0);
}
}