I am currently working on a C# script and when I run the game console will appear saying “Object reference not set to an instance of an object.”
This is where it says it. The whole second line.
//Add spheres that can be collided against
GameObject[] sp2 = GameObject.FindGameObjectsWithTag ("Softbody");
Object[] objs = GameObject.FindObjectsOfType(typeof(GameObject));
allSpheres = new ArrayList();
int cnt=0;
for(int i=0;i<sp2.Length;i++) {
allSpheres.Add(sp2[i]);
cnt++;
}
for(int i=0;i<objs.Length;i++)
{
if(objs[i].name == "SphereSoft") {
allSpheres.Add(objs[i]);
cnt++;
}
}
What I wanna know is what that means and how I can fix it.