Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

rotate player unity 2d left and right

//Rotate player 2D Left and Right
static Vector3 EscalaOriginal;

static Vector3 NovaEscala;

void Start(){

 EscalaOriginal = gameobject.transform.localScale;
 NovaEscala = new Vector3(-0.5f, EscalaOriginal.y, EscalaOriginal.z);
}

 void FixedUpdate()
    {
        //float horizontal = Input.GetAxis("Horizontal");

        //HandleMovement (horizontal); //Movement

        if (gameobject.transform.localScale != NovaEscala)
        {
            if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            {
                gameobject.transform.localScale = NovaEscala;
            }
        }

        if (gameobject.transform.localScale != EscalaOriginal)
        {
            if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            {
                gameobject.transform.localScale = EscalaOriginal;
            }
        }
    }
 
PREVIOUS NEXT
Tagged: #rotate #player #unity #left
ADD COMMENT
Topic
Name
3+2 =