Missing Animator Component error, yet I don't even ask for the component in my function

So I created a function that accesses my child objects if the player object collides with it’s parent object. Everything is pretty much working fine in the game however every time I hit this one set of blocks, it will throw in an error saying that I’m missing an Animator component for my brick break object…

Here’s my collision method:

switch (collision.gameObject.name)
    case "Player":
        if (transform.childCount == 1)
            if (gameObject.GetComponent<Block>().blockType == BlockType.QuestionCoin || gameObject.GetComponent<Block>().blockType == BlockType.QuestionItem || gameObject.GetComponent<Block>().blockType == BlockType.QuestionLife || gameObject.GetComponent<Block>().blockType == BlockType.CoinBrickBlock)
            if (gameObject.GetComponent<Block>().blockType == BlockType.QuestionCoin)
                CoinBlockCollection(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject);
            else if (gameObject.GetComponent<Block>().blockType == BlockType.QuestionItem)
                ItemBlockCollection(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject);
            else if (gameObject.GetComponent<Block>().blockType == BlockType.QuestionLife)
                LifeBlockCollection(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject);
            else if (gameObject.GetComponent<Block>().blockType == BlockType.RegBrickBlock)
                RegBrickBlock(transform.GetChild(0).gameObject, transform.GetChild(1).GetComponent<ParticleSystem>());
            else if (gameObject.GetComponent<Block>().blockType == BlockType.CoinBrickBlock)
                numOfHits++; SpecialCoinBrickBlock(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject, numOfHits);

And here’s my RegBrickBlock method:

void RegBrickBlock(GameObject brickBlock, ParticleSystem brickBreak)
    if (AudioManager.instance == null) { Debug.Log("Won't work because it's looking for audio bro. Turn on your AudioManager"); return; }
    if (smallMario.activeSelf)
        AudioManager.instance.Play("Bump Block");
    else if (bigMario.activeSelf)
        AudioManager.instance.Play("Break Block");
        brickBlock.GetComponentInParent<BoxCollider2D>().enabled = false;
        Destroy(gameObject, 1.5f);

So I’m just curious why the console is constantly throwing in this error even though I never wrote an Animator for brickBreak in the first place. Interestingly enough, the error doesn’t pop up if I remove the CoinBlockCollection and SpecialCoinBrickBlock methods, as those two are the only ones who have Animators on transform.GetChild(1).gameObject

Not sure if you are aware but this is a bug potentially:

as SpecialCoinBrickBlock() is called every time.

To fix this, delete this line:

numOfHits++; SpecialCoinBrickBlock(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject, numOfHits);

and replace it with:

SpecialCoinBrickBlock(transform.GetChild(0).gameObject, transform.GetChild(1).gameObject, ++numOfHits);

Consider refactoring this whole block:

into this:

else if (transform.childCount == 2)
    BlockType blockType = gameObject.GetComponent<Block>().blockType;
    GameObject child0 = transform.GetChild(0).gameObject;
    GameObject child1 = transform.GetChild(1).gameObject;

    if (blockType == BlockType.QuestionCoin)        CoinBlockCollection(child0, child1);
    else if (blockType == BlockType.QuestionItem)   ItemBlockCollection(child0, child1);
    else if (blockType == BlockType.QuestionLife)   LifeBlockCollection(child0, child1);
    else if (blockType == BlockType.RegBrickBlock)  RegBrickBlock(child0, child1.GetComponent<ParticleSystem>());
    else if (blockType == BlockType.CoinBrickBlock) SpecialCoinBrickBlock(child0, child1, ++numOfHits);

Easier to read and less places to make mistakes, isn’t it? It’s also slightly faster as well.

Are you 100% sure?

We probably won’t be able to help you if you won’t share the full exception message. This is step 1.

Step 2. is to pinpoint the specific line in your code that causes the exception to be thrown.