OnCollisionEnter & Get Component

So I’m wondering if there is any help ya’ll can offer on separating my walls from the obstacles. I wanted to construct my game in a way that the walls didn’t change the colors of the wall and only effected the obstacles.

I’m very new to this, so currently my ‘Objecthit’ script is identical to the course. My theory was I needed another if statement that basically said if the object i’m colliding with is the player, but the tag is “wall” return null. I’m just not quite sure if that logic is sound or how to impliment.

Any guidance would be appreciated.

Hi TomS,

I don’t know in which course and lecture you are but, in video “Using Tags” in our “Complete Unity 3D Developer: Design & Develop Games in Unity 6 using C#”, Rick shows a potential solution for your problem. With if-statements and tags, you could change the colours of specific game objects.

If the tag is “wall”, you should never get null. null would mean “no string object”.


See also:

1 Like

Privacy & Terms