Skip to content

Instantly share code, notes, and snippets.

@tak-km
Last active January 23, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tak-km/b9f9185d167fbcda428627639df3806d to your computer and use it in GitHub Desktop.
Save tak-km/b9f9185d167fbcda428627639df3806d to your computer and use it in GitHub Desktop.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
float rayRange = 100f;
void Update () {
if (Input.GetMouseButtonDown(0)) {
if(Physics.Raycast(ray,out hit)) {
Vector3 targetPos = hit.point;
Debug.Log(targetPos);
Targets [count].transform.position = targetPos;
Targets [count].GetComponent<MeshRenderer> ().enabled = true;
tList.Add (Targets [count]);
target = tList [0].transform;
agent.SetDestination(target.position);
count += 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment