void OnMouseDown() { if (gameObject.name == "boat") { action.ToggleBoat(); } else { action.ClickCharacter(character); } }
void Update() { if (Input.GetButtonDown("Fire1")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 100f)) { var todo = hit.collider; var character = todo.GetComponent <CharacterController>(); if (character) { action.ClickCharacter(character); } else if (todo.transform.name == "Boat") { action.ClickBoat(); } } } }