private void FixedUpdate() { Ray ray = new Ray(headTransform.position + headTransform.up * upOffset, headTransform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, range, raycastLayerMask) && hit.collider.GetComponent <RaycastReceiver>() != null && !(hit.collider.GetComponent <MeshRenderer>() != null && !hit.collider.GetComponent <MeshRenderer>().isVisible) ) { RaycastReceiver _currTarget = hit.collider.GetComponent <RaycastReceiver>(); if (_prevTarget != null && _prevTarget != _currTarget) { _prevTarget.OnEyeExit(); _currTarget.OnEyeEnter(); _prevTarget = _currTarget; } else if (_prevTarget == null) { _currTarget.OnEyeEnter(); _prevTarget = _currTarget; } } else if (_prevTarget != null) { _prevTarget.OnEyeExit(); _prevTarget = null; } }
private void FixedUpdate() { Ray ray = new Ray(headTransform.position + headTransform.up * upOffset, headTransform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, range, raycastLayerMask) && hit.collider.GetComponent<RaycastReceiver>() != null && !(hit.collider.GetComponent<MeshRenderer>() != null && !hit.collider.GetComponent<MeshRenderer>().isVisible) ) { RaycastReceiver _currTarget = hit.collider.GetComponent<RaycastReceiver>(); if (_prevTarget != null && _prevTarget != _currTarget) { _prevTarget.OnEyeExit(); _currTarget.OnEyeEnter(); _prevTarget = _currTarget; } else if (_prevTarget == null) { _currTarget.OnEyeEnter(); _prevTarget = _currTarget; } } else if (_prevTarget != null) { _prevTarget.OnEyeExit(); _prevTarget = null; } }
private void ReceiverEyeStared(RaycastReceiver receiver, float progress) { _mat.color = Color.Lerp(_initColor, Color.white, progress); if (progress >= 1f) { OnExit.Invoke(); } }
private void ReceiverEyeExited(RaycastReceiver receiver) { _mat.color = _initColor; }
private void ReceiverEyeStared(RaycastReceiver receiver, float progress) { _mat.color = Color.Lerp(_initColor, Color.white, progress); if (progress >= 1f) OnExit.Invoke(); }