#How can i find if a colliding GameObject has the script i am searching for?

1 messages · Page 1 of 1 (latest)

maiden knot
#

2D

velvet dawn
#

In OnCollisionEnter2D(Collision2D col),
if (col.gameObject.GetComponent<TargetScript>() != null)

maiden knot
#

thanks

jagged dew
# maiden knot thanks

If you want to use the same component in case it exists, you could use TryGetComponent instead