i have 2 scripts. MissileTrajectory.js and LockOnTest.js
MissileTrajectory is getting a target found by LockOnTest via a function called GetClosest().
The GetClosest function works 100% from within the LockOnTestScript.
there is obviously more script behind it but these are the only parts concerning the error.
MissileTrajectory.js :
private var target : GameObject;
private var lockScript;
function Start () {
lockScript = LockOnTest;
SetTarget();
}
function SetTarget(){
Debug.Log(lockScript);
var tar : GameObject = lockScript.GetClosest(); // error here
Debug.Log(tar);
if(tar == null){
Debug.Log("target is null");
return;
}
target = tar;
}
LockOnTest.js :
private var closest : GameObject;
function GetClosest () : GameObject{
if(closest !=null){
return closest;
}
}