79382774

Date: 2025-01-23 22:41:34
Score: 1.5
Natty:
Report link

The issue in this line: Debug.Log("check" + unit==null);

You're not testing whether unit is null as you might think. Instead, due to operator precedence, this statement is being evaluated like this: Debug.Log(("check" + unit) == null);

Correct Way to Check for Null: If you want to check whether unit is null and log the result, you should explicitly use parentheses to ensure the comparison happens first:

Debug.Log("check " + (unit == null));

Always use parentheses when combining comparisons and concatenation in a debug log to avoid confusion: Debug.Log("Is unit null? " + (unit == null));

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Zeeshan Tariq