AI Problem Tracking Object

Hi, I am a newbie in Unity. So, I have use this simple script to make AI track an object.

		move = true;
		// find reference for the ball transform
		GameObject ballGameObject = GameObject.Find("ball");
		if (ballGameObject == null)
			Debug.LogWarning("PlayerAI cannot find ball.");
			enabled = false;
			ballTransform = ballGameObject.transform;

The problem is when I use instantiate, the AI will not track to the instantiated object. I have also change the tag, but still it will return the log warning. So the question is, what do I need to do to make the AI works to instantiated object?

Did you try to set the tag to “Ball” and use GameObject.FindWithTag ?

Two potential issues:
-Your game object is not titled “ball” (ensure that the casing is correct).
-Your object hasn’t been created when this code has been hit.