I need to write a script where when A is pushed an object will rotate as long as its held down towards the left and when D is pushed the same will happen but it will rotate towards the right, But the thing is… I don’t know how to do that, I’m looking for some help
Here you go @Vojin2005 :
void Update () {
var speed = 20;
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(0, speed * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.D))
{
transform.Rotate(0, -speed * Time.deltaTime, 0);
}
}