This question has been answered a hundred times but I can’t find an answer that helps me. So far here is the code I have.
Object newlocation = (GameObject)Instantiate(Resources.Load("AstarTarget"));
bool going;
// Use this for initialization
void Start () {
going =false;
}
// Update is called once per frame
void Update (){
if(Input.GetMouseButtonDown(0)){ // the button is pressed
newlocation=Input.mousePosition;
going = true;}
if(going){
if((Vector3.Distance(newlocation,transform.position))>0.5f){
transform.LookAt(newlocation);
transform.Translate(Time.deltaTime, 0, Time.deltaTime);
}
}
else
going =false;
}
}
Now I’m not sure how I should word this correctly so that when I click the left mouse button it creates the prefab that the A* pathfinding will move my object to where I click on my terrain. Everything I have found either goes over my head or does not work the way I am inputting it in.