Exemple #1
0
    private void FixedUpdate()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, float.PositiveInfinity, uiLayerMask.value))
        {
            var newTarget = hit.collider.GetComponentInParent <ILaserInteractable>();
            if (newTarget != aimedAt)
            {
                if (aimedAt != null)
                {
                    aimedAt.SetHovered(false);
                }
                newTarget.SetHovered(true);
                aimedAt     = newTarget;
                line.EndPos = hit.distance * Vector3.forward;

                AudioSource.PlayClipAtPoint(mouserollSFX, this.transform.position, 0.3f);
                Debug.Log("aiming at " + aimedAt);
            }
        }
        else if (aimedAt != null)
        {
            aimedAt.SetHovered(false);
            aimedAt     = null;
            line.EndPos = 100.0f * Vector3.forward;
        }
    }