void ProcessInput() { if (Input.GetMouseButtonDown(1)) { LevelManager.instance.CancelAction(); actionPoint = Vector3.zero; Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, walkableLayer)) { agent.SetDestination(hit.point); } if (Physics.Raycast(ray, out hit, Mathf.Infinity, collectibleLayer)) { pickupTarget = hit.collider.gameObject.GetComponent <CollectibleGameObject>(); agent.SetDestination(hit.point); } else { pickupTarget = null; } } else if (Input.GetMouseButtonDown(0) && LevelManager.instance.IsActionSelected()) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, walkableLayer)) { actionPoint = hit.point; agent.SetDestination(hit.point); } } if (Input.GetKeyDown(KeyCode.Alpha1)) { LevelManager.instance.SelectAction(0); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { LevelManager.instance.SelectAction(1); } else if (Input.GetKeyDown(KeyCode.Alpha3)) { LevelManager.instance.SelectAction(2); } }
void ProcessInput() { if (Input.GetMouseButtonDown(1)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, walkableLayer)) { agent.SetDestination(hit.point); } if (Physics.Raycast(ray, out hit, Mathf.Infinity, collectibleLayer)) { pickupTarget = hit.collider.gameObject.GetComponent <CollectibleGameObject>(); agent.SetDestination(hit.point); } else { pickupTarget = null; } } }