コード例 #1
0
ファイル: Pointer.cs プロジェクト: lthiell/EscapeGame
    private void UpdateLine()
    {
        // Entfernung oder maximale Länge
        PointerEventData data         = m_InputModule.GetData();
        float            targetLength = data.pointerCurrentRaycast.distance == 0
            ? m_DefaultLength
            : data.pointerCurrentRaycast.distance;

        // Raycasting
        RaycastHit hit = CreateRaycast(targetLength);

        // Endposition des Strahls auf maximale Länge setzen
        Vector3 endPosition = transform.position + (transform.forward * targetLength);

        // Wenn ein Collider getroffen wurde, Endposition des Strahls auf diesen Punkt setzen
        if (hit.collider != null)
        {
            endPosition = hit.point;
        }

        // Kugel an die Endposition platzieren
        m_Dot.transform.position = endPosition;
        // Linie rendern
        m_LineRenderer.SetPosition(0, transform.position);
        m_LineRenderer.SetPosition(1, endPosition);
    }
コード例 #2
0
ファイル: Pointer.cs プロジェクト: nuramiera/Module1
    private void UpdateLine()
    {
        //Use default or distance
        PointerEventData data         = m_InputModule.GetData();
        float            targetLength = data.pointerCurrentRaycast.distance == 0 ? m_DefaultLength : data.pointerCurrentRaycast.distance;

        //Raycast
        RaycastHit hit = CreateRaycast(targetLength);

        //Default
        Vector3 endPosition = transform.position + (transform.forward * targetLength);

        //or based on hit
        if (hit.collider != null)
        {
            endPosition = hit.point;
        }

        //Set position of the dot
        m_Dot.transform.position = endPosition;

        //Set linerenderer
        m_LineRenderer.SetPosition(0, transform.position);
        m_LineRenderer.SetPosition(1, endPosition);
    }
コード例 #3
0
    private void UpdateLine()
    {
        // use default or distance
        PointerEventData data = vRInput.GetData();

        float tarLength = data.pointerCurrentRaycast.distance == 0 ? defaultLength : data.pointerCurrentRaycast.distance;

        // raycast
        RaycastHit hit = CreateRaycast(tarLength);

        // default
        Vector3 endPos = transform.position + (transform.forward * tarLength);

        // or based on hit
        if (hit.collider != null)
        {
            endPos = hit.point;
        }

        // set position of dot
        dot.transform.position = endPos;

        // set linerenderer
        line.SetPosition(0, transform.position);
        line.SetPosition(1, endPos);
    }
コード例 #4
0
ファイル: LaserPointer.cs プロジェクト: nan-anya/GolLang
    private void UpdateLine()
    {
        // 이벤트 가져오기
        PointerEventData data = m_InputModule.GetData();

        // 거리 구하기
        // 닿는게 없으면 기본거리, 있으면 닿은 점까지 거리
        float targetLength = data.pointerCurrentRaycast.distance == 0 ? m_DefaultLength : data.pointerCurrentRaycast.distance;
        // float targetLength = m_DefaultLength;

        // 히트 정보
        RaycastHit hit = CreateRaycast(targetLength);

        // 레이저 끝나는 지점 계산
        Vector3 endPosition = transform.position + (transform.forward * targetLength);

        // 히트가 있으면 히트한 지점
        if (hit.collider != null)
        {
            endPosition = hit.point;
        }

        // 끝점 위치
        m_Dot.transform.position = endPosition;

        // 레이저 그리기
        m_LineRender.SetPosition(0, transform.position);
        m_LineRender.SetPosition(1, endPosition);
    }
コード例 #5
0
        private RaycastHit CreateRaycast(int Layer)
        {
            PointerEventData Data = InputModule.GetData();

            Length = Data.pointerCurrentRaycast.distance <= 0.0f ? Distance : Data.pointerCurrentRaycast.distance;

            RaycastHit Hit;
            Ray        Ray = new Ray(LineOrigin.position, LineOrigin.forward);

            Physics.Raycast(Ray, out Hit, Length, Layer);

            return(Hit);
        }
コード例 #6
0
    private void UpdateLine()
    {
        PointerEventData data         = m_InputModule.GetData();
        float            targetLength = data.pointerCurrentRaycast.distance == 0 ? m_DefaultLength : data.pointerCurrentRaycast.distance;
        RaycastHit       hit          = CreateRaycast(targetLength);
        Vector3          endPosition  = transform.position + (transform.forward * targetLength);

        if (hit.collider != null)
        {
            endPosition = hit.point;
        }

        m_LineRenderer.SetPosition(0, transform.position);
        m_LineRenderer.SetPosition(1, endPosition);
    }
コード例 #7
0
ファイル: Pointer.cs プロジェクト: MathiasWahl/EiT
    private void UpdateLine()
    {
        PointerEventData data         = m_InputModule.GetData();
        float            targetLength = data.pointerCurrentRaycast.distance == 0 ? m_CurrentLength : data.pointerCurrentRaycast.distance;

        RaycastHit hit = CreateRaycast(m_CurrentLength);


        Vector3 endPosition = transform.position + (transform.forward * targetLength);


        //while (hit.collider == null && ControllerGrabObject.grab == true) { } ;

        if (hit.collider != null && Math.Pow(2, hit.collider.gameObject.layer) != dotMask.value)
        {
            endPosition = hit.point;

            //if (ControllerGrabObject.grab == true)
            //{
            //    m_CurrentLength = (float)Math.Sqrt(Math.Pow(endPosition.x, 2) + Math.Pow(endPosition.y, 2) + Math.Pow(endPosition.z, 2));
            //}
            //else if (ControllerGrabObject.grab != true)
            //{
            //    m_CurrentLength = m_DefaultLength;
            //}

            //Debug.Log(m_CurrentLength);

            if (Math.Pow(2, hit.collider.gameObject.layer) == teleportMask.value && teleportAction.GetStateUp(handType))
            {
                Teleport(hit.point);
            }
        }


        m_Dot.transform.position = endPosition;

        m_LineRenderer.SetPosition(0, transform.position);
        m_LineRenderer.SetPosition(1, endPosition);


        zLength = Vector3.Distance(transform.position, endPosition);

        //laserColider.size = new Vector3(0.01f, 0.01f, zLength);
        laserColider.center = new Vector3(0.01f, 0.01f, zLength + 0.05f);
    }