This script rotates my ship, but i want it to strafe, help?

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); 
     } 
	 

}

Change your rotate to Translate.

if(Input.GetAxis("Horizontal") > 0.0){ //if the right arrow is pressed 
      transform.Translate(0.0, turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //and then turn the plane 
   }

Thank you for the answer, i tried your code and it sends the ship straight up in the air, what in the code should i change to make it go right/left?

Thank you.

Put your values in the X of the vector 3. Right now they are in Y.

Which is why it is going up.

Ah yes ofc, thank you very much, works well now.

heh… I wonder what “0.0 * Time.deltaTime” equals…

Beat you to it this time BMB :smile: