private void MakeSimpleSelection() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity); SelectableUnit selectedUnit = null; foreach (RaycastHit hit in hits) { selectedUnit = hit.collider.gameObject.GetComponentInParent <SelectableUnit>(); if (selectedUnit != null) { break; } } if (selectedUnit != null) { //seleccionamos algo if (!selectedUnits.Contains(selectedUnit)) { selectedUnits.Add(selectedUnit); } } else { //no seleccionamos if (!Input.GetKey(KeyCode.LeftControl)) { Deselect(); } } foreach (SelectableUnit unit in selectedUnits) { unit.SelectUnit(); } }
private void Awake() { navAgent = GetComponent <NavMeshAgent>(); anim = GetComponentInChildren <Animator>(); selectable = GetComponent <SelectableUnit>(); }