# How to deal with tags in a component

I have a component called "ReflectOffCollision". This component should obviously not need to be aware of specific details about the game such as tags. The problem is, I want to apply this script to an object that reflects off of only some collisions.

I could check the tag of the collision, but this will destroy the generality of the component. It will only work on collisions with this tag. I could have the script take a white list or black list of tags, but this is awkward to do.

My other option is to inherit from the component and make a more specific version. This seems like overkill, though.

How should I deal with tags in components? I see this problem anywhere that there are collisions. Am I using tags incorrectly, or misunderstanding them?

• Does your object (which has this script) collide "normally" with Objects which would not trigger this Script? Oct 7 '14 at 14:22
• Yeah. In this particular case, I want this object to reflect off of the level mesh, but behave differently when colliding with a player object.
– Ben
Oct 7 '14 at 14:23

if(collision.gameObject.GetComponent<Reflectable>()!=null)