Example #1
0
    private void Update()
    {
        if (openMenuAction.GetState(menuHand))
        {
            if (!menuPressed)
            {
                menuPressed = true;
                menuObject.SetActive(!menuObject.activeSelf);

                if (menuObject.activeSelf && activeHand == laserPointerLeft && pointerActive)
                {
                    activeHand.ToggleLaser(false);
                    pointerActive = false;
                }
            }
        }
        else if (menuPressed)
        {
            menuPressed = false;
        }

        if (pointerActive && playerRB.velocity.magnitude > pointerMoveSpeedTreshold)
        {
            activeHand.ToggleLaser(false);
            pointerActive = false;
        }

        if (clickAction.GetState(SteamVR_Input_Sources.RightHand))
        {
            if (activeHand == laserPointerLeft)
            {
                activeHand.ToggleLaser(false);
                pointerActive = false;
                activeHand    = laserPointerRight;
            }

            if (!pointerActive)
            {
                activeHand.ToggleLaser(true);
                pointerActive = true;
            }
        }
        else if (clickAction.GetState(SteamVR_Input_Sources.LeftHand))
        {
            if (activeHand == laserPointerRight)
            {
                activeHand.ToggleLaser(false);
                pointerActive = false;
                activeHand    = laserPointerLeft;
            }

            if (!pointerActive && !menuObject.activeSelf)
            {
                activeHand.ToggleLaser(true);
                pointerActive = true;
            }
        }
    }
Example #2
0
 private void Start()
 {
     activeHand = laserPointerRight;
     activeHand.ToggleLaser(true);
     playerRB = transform.root.GetComponent <Rigidbody>();
 }