void Update() { if (CheckIfEnemyHover()) { NodeDeselected?.Invoke(); Debug.Log("Hovering enemy"); } else if (CheckIfTowerHover()) { NodeDeselected?.Invoke(); Debug.Log("Hovering Tower"); } else { CheckIfNodeMouseHover(); Debug.Log("Hovering Node"); } if (mouse.rightButton.wasPressedThisFrame) { if (!PlayerAttack()) { MoveToPoint(); } } if (mouse.leftButton.wasPressedThisFrame) { BuildTurret(); } }
void CheckIfNodeMouseHover() { NodeDeselected?.Invoke(); RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(mouse.position.ReadValue()); if (Physics.Raycast(ray, out hit, Mathf.Infinity, nodeLayer)) { NodeSelected?.Invoke(hit.transform.position); } }