hello i am making a game following a tutorial. i was here:
3. Unity3d Tutorial - Enemy AI 1/2 - YouTube
i was trying to make a line between my player and the enemy but it doesnt show up, i did exactly as he did and i got this.
NullReferenceException
UnityEngine.Transform.get_position () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:771)
EnemyAI.Update () (at Assets/hach and slash scripts/EnemyAI.cs:26)
please someone help me!
btw here is the enemy AI code:
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);
// look at target
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position, myTransform.position), rotationSpeed * Time.deltaTime);
}
}
the error came in this line:
Debug.DrawLine(target.position, myTransform.position, Color.yellow);