- Home /
Question by
thendricks · Sep 08, 2012 at 08:39 PM ·
rotatespaceshooterpress
How do I get my spaceship to rotate
I'm creating a space shooter and I need my space ship to be able to rotate ,like a car just up and down as-well, when I press an arrow key(W/up d/right...etc) in-case you need it here's my move script.
#pragma strict
var accelSpeed = 0.1;
var speed : float;
var dir : Vector2;
function Update(){
transform.position += dir.normalized * speed;
if(Input.GetButton("Jump")){
AddSpeed();
}else{
SubSpeed();
}
if(speed < 0 ){
speed = 0;
}
if(speed > 8 ){
speed = 8;
}
}
function AddSpeed(){
speed = speed + accelSpeed;
}
function SubSpeed(){
speed = speed - (accelSpeed / 2);
}
thanks in advanced
Comment
Answer by Cold_Ankles · Sep 09, 2012 at 03:36 AM
var turn : float = Input.GetAxis("Horizontal")*turnSpeed;
transform.Rotate(0,turn,0);
This is what I use. turnSpeed is a variable dictating how fast you can turn. However it only works for me when it is the only rotational movement I am doing. Change the input however you like.