im having a problem with the following script its ment to draw a line to the player but insted i get the following error (game still plays)
(UnassignedReferenceException: The variable target of ‘enemyAi’ has not been assigned.
You probably need to assign the target variable of the enemyAi script in the inspector.)
using UnityEngine;
using System.Collections;
public class enemyAi : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int rotationSpeed;
private Transform myTransform;
void awake()
{
myTransform = transform;
}
// Use this for initialization
void Start ()
{
GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
}
// Update is called once per frame
void Update ()
{
Debug.DrawLine(target.position, myTransform.position, Color.yellow);
}
}
getting this error now (NullReferenceException
UnityEngine.Transform.get_position () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:771)
enemyAi.Update () (at Assets/Scripts/enemyAi.cs:27))