I've made a hole. I have animals tagged as animals. When an animal walks into the hole, they disappear. I tried OnTriggerEnter2D()
as well, and set the collider to isTrigger
, but it still didn't work. I can get it to work without the tag part, but anything that bumps into each other sets each other to inactive.
public class BlackHole : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "animal")
{
other.gameObject.SetActive(false);
}
}
}