Example #1
0
        private void Update()
        {
            RaycastHit hit;
            Vector3    fwd = transform.TransformDirection(Vector3.forward);

            int mask = 1 << LayerMask.NameToLayer(exludeLayerName) | layerMaskInteract.value;

            if (Physics.Raycast(transform.position, fwd, out hit, rayLength, mask))
            {
                if (hit.collider.CompareTag(interactableTag))
                {
                    if (!doOnce)
                    {
                        raycasted_obj = hit.collider.gameObject.GetComponent <SafeItemController>();
                        CrosshairChange(true);
                    }

                    isCrosshairActive = true;
                    doOnce            = true;

                    if (Input.GetKeyDown(SafeInputManager.instance.openKey))
                    {
                        raycasted_obj.ShowSafeLock();
                    }
                }
            }

            else
            {
                if (isCrosshairActive)
                {
                    CrosshairChange(false);
                    doOnce = false;
                }
            }
        }