How to count object with tag using OnTriggerEnter ?
I used this script, but it didn’t give me correct number.
public int weapons= 0;
void OnTriggerEnter(Collider other)
{
print(other.gameObject.name);
if (other.gameObject.tag == “weapons”)
{
weapons++;
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == “weapons”)
{
weapons–;
}
}