private void OnTriggerEnter(Collider other) { FenceHealth health = other.gameObject.GetComponent <FenceHealth>(); if (health != null) { targetsHealth = health; onCollidedWithFence?.Invoke(); } }
private void Start() { _healthBarSlider = _healthBarGameObject.GetComponent <Slider>(); _health = gameObject.GetComponent <FenceHealth>(); if (_health == null) { Debug.LogError("Attach Health script"); } _repairPopUpGameObject.SetActive(false); _healthBarGameObject.SetActive(false); _health.SetHealthSlider(_healthBarSlider); _healthBarPosition = _healthBarGameObject.transform.position; status = FenceStatus.Fixed; _health.OnFenceDestroyed += FenceIsDestroyed; _health.OnFenceDamaged += FenceDamaged; CameraFollow.CameraFollowInstance.OnCameraMoved += DisableFenceUI; CameraFollow.CameraFollowInstance.OnCameraOnCamp += EnableFenceUI; }
private void OnTriggerExit(Collider other) { targetsHealth = null; }