I have a simple two codes to move object to spots. But i have two null errors,at start of the game : NullReferenceException at : follower = GameObject.Find (“Follower”).GetComponent< Follower >(); and second when im clicking at the object with a script Leaders :NullReferenceException: Object reference not set to an instance of an object at : follower.v3Dest = transform.position; Thank for any help!
public class Follower : MonoBehaviour
{
public Vector3 v3Dest;
public float speed = 5.0f;
void Start () {
v3Dest = transform.position;
}
void Update () {
transform.position = Vector3.MoveTowards(transform.position,v3Dest,Time.deltaTime * speed);
transform.LookAt(v3Dest);
}
}
And this script goes on any objects (i.e. the things you click on to change the destination):
public class Leaders : MonoBehaviour {
private Follower follower;
void Start () {
follower = GameObject.Find (“Follower”).GetComponent< Follower >();
}
void OnMouseDown() {
follower.v3Dest = transform.position;
}
}