private bool PlayerCanInteract(PlayerManager currentPlayer) { FieldOfView fieldViewManager = Camera.main.GetComponent <CameraManager>().FieldOfView; if (!fieldViewManager.IsObjectVisibleFromPlayer(currentPlayer.gameObject, this.transform.parent.gameObject)) { return(false); } bool result = false; BaseSwitch[] allSwitch = transform.parent.GetComponents <BaseSwitch>(); foreach (var switchActiv in allSwitch) { if (currentPlayer.gameObject.IsTagValid(switchActiv.TagSelection)) { CurrentInteractionAvailable = switchActiv; result = true; } } if (!result) { CurrentInteractionAvailable = null; } return(result); }
public void PlayerInteract() { CurrentInteractionAvailable?.OnActivate(); CurrentInteractionAvailable = null; }