- Home /
Checking Tag of Trigger Prefab
I have a ball which I would like to pass through two triggers.
For the first trigger I have the script placed on the ball, which will add a counter to the ball as well as mark it for respawning at the top of the screen.
The second trigger will make instantiate copy of this ball.
I would like to write an if statement to check which trigger is which by using the tags, but I am unable to figure this out.
My best guess/google result is so far incorrect, it only works for the ball's tag and not the trigger's tag (linetag).
void OnTriggerEnter2D(Collider2D twoPointBalls)
{
if (gameObject.tag == "linetag")
{
//do stuff
}
How can I check the tag (on a prefab) of a Trigger?
Answer by ivomarel · May 20, 2014 at 10:47 PM
if (twoPointBalls.tag == "linetag") { //do stuff }
ivomarel, it must have been there the whole time, I just didn't get it. Thank you for explaining it to me! Works perfect!