// Update is called once per frame void Update() { if(!init) { Initialize(); } if(Input.GetMouseButtonDown(mouseButtonToMove)) { //Get mouse position Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(ray, out hit); //Set Mouse Point to INT for GRID prefabTarget.transform.position = new Vector3(Mathf.RoundToInt(hit.point.x), 0, Mathf.RoundToInt(hit.point.z)); //Set new path newPath = true; GRIDPath gridPathObject = new GRIDPath(prefabParent, terrain); nodeList = gridPathObject.FindNewPath(prefabParent.transform.position, prefabTarget.transform.position); } if(newPath) { PathMovement(); } }
// Update is called once per frame void Update() { if (!init) { Initialize(); } if (Input.GetMouseButtonDown(mouseButtonToMove)) { //Get mouse position Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(ray, out hit); //Set Mouse Point to INT for GRID prefabTarget.transform.position = new Vector3(Mathf.RoundToInt(hit.point.x), 0, Mathf.RoundToInt(hit.point.z)); //Set new path newPath = true; GRIDPath gridPathObject = new GRIDPath(prefabParent, terrain); nodeList = gridPathObject.FindNewPath(prefabParent.transform.position, prefabTarget.transform.position); } if (newPath) { PathMovement(); } }