Hello guys,
i hav difficulties with my colliders. To b specific, OnTriggerEnter2D. I attached my OnTriggerEnter script to all my game objects. But now, i want the colliders to report the collision for just 1 of the gameOBJECTS but instead, it reported two because the collider script was in both gameobjects. Please, i need ur help,
i hav difficulties with my colliders. To b specific, OnTriggerEnter2D. I attached my OnTriggerEnter script to all my game objects. But now, i want the colliders to report the collision for just 1 of the gameOBJECTS but instead, it reported two because the collider script was in both gameobjects. Please, i need ur help
Hi
It’s not necessary to dublicate your title and message.
A piece if code will be great so we can see what exactly if wrong with your trigger check
To get report only for specific collision you need to make a check if your trigger collided with the object of specific type/name/tag/layer
Here is an example
void OnTriggerEnter2D(Collider2D col)
{
//if you want to check collision by tag
if(col.gameObject.tag == "TARGET_TAG")
{
//this trigger collided with object with tag TARGET_TAG
}
}
You can do the same way if you want to check if collided object has a specific name or layer or component.