Animation to decrease the size of a cube in Unity

0

Hello! I'm in Unity using C # and I have a cube that when I press 'q', it decreases to 0.5 of scale starting from scale 1 and when I release 'q', it goes back to scale 1. I wanted there to be some quick animation of the decay and growth of the cube and I thought of making a For that, am I right? Is there a specific function for this?

    
asked by anonymous 11.05.2018 / 05:10

1 answer

0

Use DOtween: link

int duracao = 5;
    private void Update()
    {

        if (Input.GetKeyDown(KeyCode.Q))
        {
            gameObject.transform.DOScale( new Vector3(0.5f, 0.5f, 0.5f), duracao);
        }

        if (Input.GetKeyUp(KeyCode.Q))
        {
            gameObject.transform.DOScale(new Vector3(1, 1, 1), duracao);
        }
    }
    
27.05.2018 / 04:51