private void HighlightNearestInteractable() { if (_distanceDetector.GetColliders().Count == 0) { return; } var interactable = _distanceDetector.GetNearestCollider(_transform.position).GetComponent <Interactable>(); if (_hasHighlighted) { _currentHighlighted.UnHighlight(); } interactable.Highlight(); _currentHighlighted = interactable; _hasHighlighted = true; }
protected bool PlayerInsideRange() { var colliders = _distanceDetector.GetColliders(); if (colliders.Count == 0) { return(false); } var position = transform.position; Debug.DrawLine(position, colliders[0].position); var hit = Physics2D.Linecast(position, colliders[0].position, hitLayers); var hitTransform = hit.transform; if (hitTransform == null) { return(true); } var isPlayer = hitTransform.gameObject == colliders[0].gameObject; return(isPlayer); }