- Home /
Question by
AlexTheHollow · Jun 25, 2015 at 12:52 PM ·
enemyscript errortracking
Enemy tracking Script Help
I DO NOT OWN THIS SCRIPT***
It says "MissingRefenceException: the object 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.
using UnityEngine;
using System.Collections;
public class Enemy_AI : MonoBehaviour {
Transform tr_Player;
float f_RotSpeed=3.0f,f_MoveSpeed = 5.0f;
// Use this for initialization
void Start () {
tr_Player = GameObject.FindGameObjectWithTag ("Player").transform; }
// Update is called once per frame
void Update () {
/* Look at Player*/
transform.rotation = Quaternion.Slerp (transform.rotation , Quaternion.LookRotation (tr_Player.position - transform.position) , f_RotSpeed * Time.deltaTime);
/* Move at Player*/
transform.position += transform.forward * f_MoveSpeed * Time.deltaTime;
}
}
How do I fix this?
Comment
Your answer