Hello I am making a 3d side scroller and for my character im using the input.get axis to rotate the player. The thing is when I press the left key or right key twice it will still rotate the player making the character walk backwards. May someone please help me fix this?
var walkSound : AudioClip;
var soundPlaying : boolean = false;
var playerPosition : Transform;
var gunPosition : Transform;
function Start () {
}
function Update () {
if (Input.GetButtonDown(“Horizontal”))
{
if (Input.GetAxis(“Horizontal”) > 0)
{
playerPosition.transform.Rotate(0, 180, 0);
Debug.Log("right");
gunPosition.transform.Rotate(0, 180, 0);
Debug.Log("right");
}
else
{
playerPosition.transform.Rotate(0, -180, 0);
Debug.Log("left");
gunPosition.transform.Rotate(0, -180, 0);
Debug.Log("left");
}
}
if (Input.GetButtonDown ("Jump")){
audio.PlayOneShot (jumpSound);
}
if (Input.GetButtonUp ("Horizontal")){
audio.Stop ();
soundPlaying = false;
}
}
@script RequireComponent (AudioSource)