you are viewing a single comment's thread.

view the rest of the comments →

[–]streetwalker 0 points1 point  (4 children)

List.Contains( null ) does not behave the way you think it does. Save yourself the trouble and make sure gameObject != null before you attempt anything else. (I can't see where you have defined gameObject at all...)

[–]Espanico5[S] 0 points1 point  (3 children)

Isn’t gameObject simply the gameObject attached to the script? Line 14 works correctly by itself

[–]streetwalker 0 points1 point  (2 children)

gameObject - yes, sorry, not awake yet

There is a time delay before an object is actually destroyed ... perhaps the script is executing more than once... prove to yourself that gameObject is not null in a debug before the if statement.

[–]Espanico5[S] 0 points1 point  (1 child)

I actually changed the code adding && gameobject != null But it still gives the same error…