void Update() { // Check for movement inputs. if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject()) { MouseClickEvent mouseClick = MouseUtil.GetMousePositionInWorld(); targetPosition = mouseClick.point; SetMovementMarker(targetPosition); if (mouseClick.hitGameObject.tag == "Intractable") { // End old interaction if (interactedObject != null) { interactedObject.EndInteraction(); } // Interact with object interactedObject = mouseClick.hitGameObject.gameObject.GetComponent <Interactable>(); interactedObject.SetInteraction(agentController); } else { agentController.MoveToPosition(targetPosition); if (interactedObject) { // Stop focusing on an Item. interactedObject.EndInteraction(); } } UIEventHandler.ContainerClosed(); UIEventHandler.DialogInterrupted(); } if (agentController.HasReachedDestination()) { RemoveMovementMarker(); } else { SetMovementMarker(agentController.GetAgentDestination()); } }