Esempio n. 1
0
    private void SetMarkerPosition()
    {
        Vector3 target = _gazeMag.LastGazePos;

        target.y = 0f;
        _teleportMarker.transform.position = target;

        if (_markerCollider.HasCollided())
        {
            _teleportMarker.transform.position = _markerCollider.GetAdjustedPosition();
        }
    }
    private void UpdateArc()
    {
        if (SteamVR_Actions.default_TouchPad[SteamVR_Input_Sources.RightHand].axis == Vector2.zero)
        {
            if (IsArcActive)
            {
                _arc.Hide();
                _teleportMarker.SetAlpha(0f, 0f);
            }
            IsArcActive = false;
            return;
        }

        IsArcActive = true;
        Vector3 arcVelocity = _aimAnchor.forward * _maxDistance;

        _arc.SetArcData(_aimAnchor.position, arcVelocity, true, false);

        bool didHit = _arc.DrawArc(out RaycastHit hit);

        if (didHit)
        {
            _arcTarget        = hit.point;
            _isArcTargetValid = true;
            _arc.SetColor(Color.green);

            _teleportMarker.transform.position = hit.point;
            _log.Append("origTarget", hit.point);

            Vector3 markerPos;
            if (_markerCollider.HasCollided())
            {
                markerPos   = _markerCollider.GetAdjustedPosition();
                markerPos.y = hit.point.y;
                _teleportMarker.transform.position = markerPos;

                _log.Append("shiftedTarget", markerPos);
            }

            _teleportMarker.SetAlpha(1f, 1f);
        }

        if (!didHit || hit.collider.gameObject.layer != 12)
        {
            _arc.SetColor(Color.red);
            _teleportMarker.SetAlpha(0f, 0f);
            _isArcTargetValid = false;
        }
        _arc.Show();
        _log.Append("targetValid", _isArcTargetValid);
    }