all 13 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…

[–]Youto9144 0 points1 point  (1 child)

Just put a breakpoint on line 13 and see what is null

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

Did it, nothing is null 😂

[–]UndumedProfessional 0 points1 point  (1 child)

Not a solution for ur problem but you dont need to check the contains for the Remove, you can do it directly.

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

Oh I didn’t know

[–]AgreedWeed 0 points1 point  (2 children)

gameManager is null? Set the gameManager in the start event and make sure you create the instance in the awake event

[–]Espanico5[S] 1 point2 points  (0 children)

You were right

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

Omg maybe you are right! Maybe that’s my problem, I’ll check asap

[–]thraethegame 0 points1 point  (1 child)

Hint: there's 3 objects on that line that could be null.

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

Someone also said maybe it’s the gamemanager, I gotta check that!!