// Update is called once per frame void Update() { //if we are not clicking over an UI, we continue if (EventSystem.current.IsPointerOverGameObject()) { return; } if (Input.GetMouseButtonDown(0)) { //ray casting to detect where we clicked Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //if an hit happens.. if (Physics.Raycast(ray, out hit, 100, movementMask)) { //Debug.Log(hit.point); motor.MoveTo(hit.point); } RemoveFocus(); } if (Input.GetMouseButtonDown(1)) { //ray casting to detect where we clicked Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //if an hit happens if (Physics.Raycast(ray, out hit, 100)) { Interactable interactable = hit.collider.GetComponent <Interactable>(); //if its an interactable. focus if (interactable != null) { SetFocus(interactable); } } } }