Hello!
So I’ve made a script that automatically adds child objects to a list on Start().
Here’s what I’m doing:
public List<Transform> WalkFrames;
void Start()
{
foreach (Transform child in WalkFramesParent)
{
Debug.Log("Found child: " + child.name);
WalkFrames.Add(child); //This is where the error is
WalkFramesLength++;
}
}
Now if I make the List public, it works great. However, if it’s private, I get this error (even though the Debug.Log fires once):
NullReferenceException: Object reference not set to an instance of an object
CharachterAnimator.Start () (at Assets/CharachterAnimator.cs:33)
Any idea as to why this happens? It really doesn’t inhibit me much, this question is just out of personal curiosity.
Thanks.