Example #1
0
    private void UpdateTargetMarker()
    {
        GameObject target = TargetManager.CurrentTarget;

        if (target == null || !target.activeSelf)
        {
            DeactivateChildren();
        }
        else
        {
            Vector3 headPos         = DepthRayManager.Instance.HeadPosition;
            Vector3 targetPos       = target.transform.position;
            Vector3 rayDirection    = CustomRay.RayDirection();
            Vector3 targetDirection = (targetPos - headPos).normalized;

            float angleBetween = Vector3.Angle(rayDirection, targetDirection);

            if (angleBetween > 5)
            {
                Color color = targetFinderMaterial.color;
                color.a = Mathf.Pow(Mathf.Abs(angleBetween) / 180f, 0.25f);
                targetFinderMaterial.color = color;
                ActivateChildren();
                transform.forward = targetPos - transform.position;
            }
            else
            {
                DeactivateChildren();
            }
        }
    }