I need help!I try to find out how to check if the game object(prefab with tag)is null so that when it is destroyed the script is giving no error back because of it.I cannot destroy the script after destruction of the gameobject/target because the prefab will be respawned again and will later tap into the same script.Any suggestions??
var spawnRange = 5.0;
private var target : Transform;
private var outsideRange = true;
private var distanceToPlayer;
//---------------------------------------------------------
function Update()
{
target = GameObject.FindWithTag("friend").transform;
//***here the target must be checked!!!***
distanceToPlayer = transform.position - target.position;
if (distanceToPlayer.magnitude < spawnRange)
{
animation.Play("cubecolliderani");
outsideRange = false;
}
else
{
outsideRange = true;
}
}