Hey, i have two scripts, one called targeting which has the public game object “attackingCity” in it. In the other script, i have a private variable of type targeting called “targetRef”.
I have set the attackingCity variable to cityE and when I Debug.Log it from the targeting script it confirms this. When i try and call this city from the other script using Debug.Log(targetRef.attackingCity); it throws a null reference exception at me.
You are not properly settings the refernce. Perhaps post your method here, but, it should look something like this
var TargetReference : GameObject ;
function Start ( )
{
TargetReference = GameObject.Find ( "ObjectName" ) ;
//OR
TargetReference = GetComponent ( ScriptComponentNameWithout.CS ) ;
}