It says “Object reference not set to an instance of an object” at line 92. I know what’s wrong with generating script math, that isn’t the problem. Any idea what’s wrong?
GridCube is most likely null.
That’s why this is so wierd. It is not null.
Hm. Peculiar. Not entirely sure. If you are simply adding an object to a list, it should not be an issue if the object is properly assigned. You did a check…
… At line 92, just prior,
print("gridCube " + gridCube);
See if this reports an object.
gridCube gridCube(Clone) (UnityEngine.GameObject)
UnityEngine.MonoBehaviour:print(Object)
GridController:snapPoint(GameObject) (at Assets/Game_scripts/GridController.cs:92)
BuildScript:FixedUpdate() (at Assets/Game_scripts/BuildScript.cs:69)
I posted as c# code because of smileys.
Bumb.
So gridCube exists? it is assigned?
If it returns a GameObject I guess so.
Unsure man.
Well I don’t understand how it could return a value if it isn’t assigned.
So you continue to get the same error?
Line 92 would throw that error if the list was null - which you set it to in Clear() so my guess is you’re calling Clear and then trying to call snapPoint aftewards without re-initializing the list.
@renman3000 - gridCube can be null. Adding null to a list is allowed.
Yes, it doesn’t throw that error anymore after commenting use of the Clear function.
Thank you so much, now I think I can fix it.
So I got some new problems… Updated scripts:
When line 70 in BuildScript is uncommented line it won’t log debug message in line 31. This affects that locaPositionList doesn’t have proper assignation.