CS1061 error with Tags

Hello. I have coded my page, I think, exactly as needed. I am getting this error.

“Assets/Scripts/Block.cs(27,19): error CS1061: ‘Level’ does not contain a definition for ‘CountBlocks’ and no accessible extension method ‘CountBlocks’ accepting a first argument of type ‘Level’ could be found”

The error is appearing on the level.CountBlocks():

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Block : MonoBehaviour
{
//[SerializeField] AudioClip breakSound;

[SerializeField] GameObject blockSparklesVFX;


Level level;


private void Start()

{
    CountBreakableBlocks();

}

private void CountBreakableBlocks()
{
    level = FindObjectOfType<Level>();
    if (tag == "Breakable")
    {
        level.CountBlocks();
    }
}

private void OnCollisionEnter2D(Collision2D collision)
{
    if (tag == "Breakable")
    {
        DestroyBlock();
    }

}

private void DestroyBlock()
{
    FindObjectOfType<GameStatus>().AddToScore();
    //AudioSource.PlayClipAtPoint(breakSound, Camera.main.transform.position);
    DestroyObject(gameObject);
    level.BlockDestroyed();
    TriggerSparklesVFX();
 }


private void TriggerSparklesVFX()
{
    GameObject sparkles = Instantiate(blockSparklesVFX, transform.position, transform.rotation);
    Destroy(sparkles, 1f);
}

}

The blocks have been correctly identified as breakable or unbreakable.

Any help would be appreciated.
Brian

I solved the issue. i believe, i had duplicated a call. I adjusted the code and things work fine.

Thank you.

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

Privacy & Terms