//This is an enemy AI script that i am trying to make.
var moveSpeed = 0.5;
var player : Transform;
var killzone = 10.00;
var personolspace = 5.00;
var playerALL : GameObject;
var playerHealth = 100;
var attackStrength = 1;
var one : GameObject;
var two : GameObject;
var three : GameObject;
var four : GameObject;
var five : GameObject;
function Update () {
if (playerALL !== null playerHealth <= 0 playerALL playerALL != null) {
Destroy(playerALL);
Destroy(one);
Destroy(two);
Destroy(three);
Destroy(four);
Destroy(five);
}
if (playerALL !== null Vector3.Distance(transform.position,player.position) <= personolspace playerALL != null) {
playerHealth = playerHealth - attackStrength;
print("You’re health is " + playerHealth);
}
if (playerALL !== null playerHealth > 0 Vector3.Distance(transform.position,player.position) <= killzone Vector3.Distance(transform.position,player.position) >= personolspace) {
transform.LookAt(player);
transform.position += transform.forwardmoveSpeedTime.deltaTime;
}
if (playerALL == null) {
print (“You died!”);
}
here is the error after the AI destroys me :
MissingReferenceException: The object of type ‘Transform’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Transform.get_position () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineTransform.cs:19)
NewAIScript.Update () (at Assets/NewAIScript.js:25)