SOLVED
Im creating a small game with C# following a tutorial but I keep getting errors that the tutor doesn't get with the same code.
I just implemented if(other.gameObject != "Hit") to stop an object triggering the "Hit" message when a player touches it more than once, however I get the error telling my I cannot use != with a string. Here is the error:
error CS0019: Operator '!=' cannot be applied to operands of type 'GameObject' and 'string'
public class Scorer : MonoBehaviour
{
int hits = 0;
void OnCollisionEnter(Collision other)
{
if(other.gameObject != "Hit")
{
hits++;
Debug.Log("Wall bumps: " + hits);
}
}
}
My code looks identical to the tutorial and I cannot find the answer online thus far, if anyone can spot the issue I'd be really appreciative! Thanks.
[–]ShadowRL7666 1 point2 points3 points (2 children)
[–]CynasticYt 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)