Hello, I want to access an object from a component which I purposefully set to null in the constructor (Start()). It is part of a doubly linked list, and as such the first and last objects will be null. The problem is so… ridiculous. When accessing the object to test if it is null, I get a NullReferenceException. Is there any way to fix that (please say yes).
void LateUpdate()
{
// Call the follow script on children after we have moved.
GameObject child = GetComponent<Attach>().myChild;
if (child != null)
child.GetComponent<Attach>().followParent();
}
It will throw the error on the first GetComponent line.