I've just really gotten started in Unity and while documentation has been helpful I haven't figure out how to detect collisions with 2 or more objects. I was able to get a script working that plays a sound when I touch the pressure plate with the player but I don't know how I would do something when 2 objects are within the collider but undo it when one of them leaves the area.
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
AudioSource.PlayClipAtPoint(Sound, transform.position);
}
}
}
Am I going about this the wrong way by using OnTriggerEnter2D? I see that there is a mass component on Rigidbodies but I don't know if I should be using it because I am still a novice in Unity. I'm also aware of OnCollisionExit but I don't think that works in this case because I'm currently only detecting 1 object but I need to detect 2. I was able to find videos that somewhat helped but all of them only worked with one object and were in a 3D space rather than a 2d one.