Help with tags

Hi, I’m working on a game and I’m unsure how to code something. I’m relatively new to Unity and C# so bear with me:

Basically, I have a bunch of cubes in my scene, a certain amount of which have to be tagged “correct” before moving on to the next puzzle and resetting their tag back to default.

So far I’ve figured out how to change an objects tag with raycasts; how would I go about coding the rest?

I’m not sure that what you are trying to do needs to use the Unity’s tag system. If you have the RayCastHit object then you can simply get to the gameObject (which means you can get access to it’s component to change whatever it is you need to change).

For instance:

using UnityEngine;
using System.Collections;

public class TaggableObject : MonoBehaviour
{
    public bool Tagged { get; set; }
}

Next Script

using UnityEngine;
using System.Collections;

public class Shooter : MonoBehaviour
{
    private static int Count = 0;
	
	// Update is called once per frame
	void Update ()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 25.0f))
            {
                Debug.Log(string.Format("Hit: {0}!", hit.transform.gameObject.name));
                hit.transform.GetComponent<TaggableObject>().Tagged = true;
                ++Count;
            }
        }

        if (Count == 30) //Arbitrary number for example
        {
            //go to next level.
        }
	}
}

Let me know if this makes sense and if so I can edit the script even further to make it more like what you are trying to implement.