Refering to gameobject in other script

Maybe someone from overhere?

https://forum.unity.com/threads/refering-to-gameobject-in-other-script.783680/#post-5216231

I can’t test right now (because not behind pc with Unity on it).
My guess is that the pathfindingScript remains null, because GetComponent(); returns nothing. When you try to call pathfindingScript.nodeA or pathfindingScript.nodeB you get the null reference exception.

You could try to fix the GetComponent call by prefacing it with gameObject. Try:

pathfindingScript = gameObject.GetComponent<PathfindingScript>();

if (pathfindingScript != null)
{
   print("found it");
}
else
{
   print("no pathfindingscript found");
}

Please don’t cross post, suggestions have been offered in the other thread with no reply.