I am using the A* Pathfinding Project but getting a null reference to the IAstarAI when I GetComponent in the top level of inheritance. Same code works when I use it in the lower level. Both scripts are attached to the gameobject.
Anyone got any ideas why this happens?
Some notes on how to fix a NullReferenceException in Unity3D (also Unassigned Reference errors):
http://plbm.com/?p=221
The basic steps outlined above are:
- Identify what is null
- Identify why it is null
- Fix that.
I found the solution. I changed the start() to Awake(). I am aware the Awake() loads later but still not sure why this fixed the issue.
This is incorrect. I suggest you review the Unity Monobehavior event lifecycle chart. It is critical to your successfully engineering solutions within the Unity3D API and framework.
Here is some timing diagram help: