Collect a group of objects with the same tag and then destroy and object to progress.

I am making a 3D adventure game for a school project. I have implemented a group of pickups that get destroyed when picked up. They are all tagged with “Objective”, I have no idea how to make it so that when all of the “Objective”(s) are destroyed i want to open up the next part of the map by destroying some rubble.

Probably simplest and easiest way to do this is through UnityEvents

PickUp.cs

using UnityEngine;
using UnityEngine.Events;

public class PickUp : MonoBehaviour
{
    public UnityEvent OnPickUp;

    //call from collision, trigger, click or whatever
    public void PickUpEvent()
    {
        OnPickUp.Invoke();
        Destroy(gameObject);
    } 
}

Rubble.cs

using UnityEngine;

public class Rubble : MonoBehaviour
{
    public int AmountToClear = 3;
    int pickedUp = 0;
    public void ItemPickedUp()
    {
        pickedUp += 1;
        checkClearRubble();
    }

    void checkClearRubble()
    {
        if (pickedUp >= AmountToClear)
            gameObject.SetActive(false); //or destroy
    }
}

This way you could simply make the items notify the rubble through events when they’ve been picked up and act accordingly. UnityEvents are easy to use, just press the +sign to add new target for the event, then drag the rubble to it and select the PickUpEvent from the list.

Using the event system above as @Vipsu suggests, you can even make another event that tells the central manager that it was spawned. That way on levels with higher counts, you can have a dynamically-growing “AmountToClear” that does not have to be kept in perfect synchrony with the actual number of items available to pick up.

function Start () {
    var gos : GameObject[];
    gos = GameObject.FindGameObjectsWithTag("Objective");

    if (gos.length == 0)
    {
        Debug.Log("All Points Located");
        Destroy (gameObject);
    }
}

Do I add PickUp.cs to each pickup or do I add it to something else? I have tried a couple of variations but I cannot get your code to work. I assumed the easiest way to do this was through checking tags. I made a something with java but it does not work.

The code is not complete, you need to call the ItemPickedEvent method from where ever you want the pick-up to happen for example if you want it to happen when player touches the item you’d probably call it from OnTriggerEnter or OnCollisionEnter in PickUp.cs.

Alternatively you could implement the IPointerClickHandler from Unity.EventSystems and call it when user clicks the item or if you’re unfamiliar with interfaces you could use MonoBehaviors OnMouseDown.

Events, call-backs and such are core part of game programming, learn to use them well and you can do much more with them than this.

You probably mean Unity Script or “JavaScript”, Java is completely different programming language that has nothing to do with Unity.