I started learning Unity recently, and the following question arose: how can I specify in OnCollisionEnter() and OnTriggerEnter() only a CERTAIN object with which an event should occur? Thank you!
it’s very simple, you can use a Tag that you apply to the object you want it to do something when it enters with the collision.
the structure is identical for both OnCollison () and OnTrigger ().
Example:
private void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "ExampleTag")
{
// do something
}
}