void Target() { if (currentTarget as MonoBehaviour == null) { currentTarget = null; } RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) { ITargetable targetable = hit.transform.GetComponent <ITargetable>(); if (targetable != null) { if (currentTarget != targetable) { if (currentTarget != null) { currentTarget.Untarget(); currentTarget = null; } targetable.Target(); currentTarget = targetable; } } else { if (currentTarget != null) { currentTarget.Untarget(); currentTarget = null; } } } else { if (currentTarget != null) { currentTarget.Untarget(); currentTarget = null; } } }