Block Breaker, max tuning: special blocks that make paddle bigger

Hello all! Currently, I’m on episode 79 of the 2D Unity Course, and I’m trying to do some extreme tuning, but I’m running into a little bit of a problem.

I’ve created a new Prefab block known as “Bigger Paddle Block,” and as its name might suggest, it is supposed to increase the size of the player’s paddle when it is broken. The problem is, I can’t seem to access the paddle’s transform.scale component in order to change it.
The main function of interest is the “CheckIfSpecialBlock” function, but I’ve included some of the code surrounding it for more context.

Here’s my current code, along with the error I’m receiving from Unity:

 private void OnCollisionEnter2D(Collision2D collision)
    {

        if (tag != "Unbreakable")
        {

            TakeHit();

        } else {

            UnbreakableBlock();

        }
 

    }


    private void TakeHit()
    {

        currentHP--;

        if (currentHP < 1)
        {
            CheckIfSpecialBlock();
            DestoryBlock();
        } 
        else
        {
            ShowNextDmgLvl(currentHP);
        }

    }



    private void CheckIfSpecialBlock()
    {
        if ( tag == "Bigger Paddle")
        {

            Paddle playerPaddle = FindObjectOfType<Paddle>();

            playerPaddle.transform.scale *= 2;

        }


    }

Error: Assets\Scripts\Block.cs(96,36): error CS1061: ‘Transform’ does not contain a definition for ‘scale’ and no accessible extension method ‘scale’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?)

Any helpful pointers?

Hi @Hasec_Rainn,

Welcome to our community! :slight_smile:

Have you already checked the API? As the error message says, there is no scale defined in the Transform class but there are localScale and lossyScale.

If you replace scale with one of them, your code should work.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.