Reply To: [Solved]Count objects with tag on OnTriggerEnter ?

Forum Archive [Solved]Count objects with tag on OnTriggerEnter ? Reply To: [Solved]Count objects with tag on OnTriggerEnter ?

#38400
Jonathan Gonzalez
Participant

    @aeleas if you’re getting 2 that means it’s detecting it twice. Do you have the script on just the trigger? OnTriggerEnter only gets called once, same with OnTriggerExit. Here is what you should have:

    public int weapons;
        void OnTriggerEnter (Collider other)
        {
            if(other.CompareTag("weapons"))
                weapons++;
        }