Basically, I have a FindAndTrackEnemies script attached to my enemy entities. The problem is that a function in this script only seems to execute the first few lines except when the player spawns an attack prefab. A Debug.Log() at the top of aiDecision() (the function in question) does update in the console, however, using more Debug.Logs, it appears that the script only executes the first few lines as the others don’t register after a point. Could a null reference error or some other case cause Unity not to finish a function? I do get these with functions being called in that script, tho this seems unlikely as other functions have given me this error and have still executed to completion. Also, these functions shouldn’t even have that error based on their execution. For example, this function delivers that error…
function getTargetDistance (target : Transform) : float {
var distance : float = Vector3.Distance(transform.position, target.position);
return distance;
}
Any thoughts would be appreciated!!! Thanks in advance.