"object hit" script if statement ignoring the tag specification of "player"

the script is written same as the lecture, but whenever the object in question collides with something, even if it doesn’t have the player tag, it activates the method. why is that?!? i checked the code over and over again and i can’t seem to find the issue.

Hi,

Welcome to our community! :slight_smile:

If the code works correctly, check the Unity Editor. The spelling of the tags must be excactly the same in your code and in the Unity Editor.


See also:

heya Nina!
yeah, i checked that too. same exact spelling. any other ideas? i’ll provide pictures later.

Maybe a typo? A common mistake is a semicolon behind the parentheses of the if-statement. Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

thank you!! that was the issue!! i had put a semicolon before the curly brackets. it works now!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms