Esempio n. 1
0
    void UpdatePlayerRotation()
    {
        Vector2 lookDir;
        float   rotation;

        // If controller.
        if (Input.GetAxis("Horizontal_2") != 0 || Input.GetAxis("Vertical_2") != 0)
        {
            lookDir = new Vector2(-Input.GetAxis("Horizontal_2"), Input.GetAxis("Vertical_2"));
        }
        else // Else if mouse.
        {
            lookDir = mousePos - currentCharacterMotor.rb.position;
        }

        float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;

        currentCharacterMotor.CharactorRotator(angle);
    }