示例#1
0
    // Update is called once per frame
    void Update()
    {
        soulRing.transform.RotateAround(transform.position, transform.forward, 5);

        if (handType == SteamVR_Input_Sources.LeftHand)
        {
            score.text = player.GetNumDefeatedString();
        }
        else
        {
            score.text = player.GetTimeString();
        }


        RaycastHit hit;

        if (Physics.Raycast(controllerPose.transform.position, transform.forward, out hit, Mathf.Infinity, columnMask))
        {
            hitPoint = hit.point;
            GameObject hitColumn = hit.collider.gameObject;

            // There is already a selectedColumn
            if (selectedColumn != null)
            {
                // If the selectedColumn and hitColumn are different, set the selectedColumn to hitColumn
                if (hitColumn.GetInstanceID() != selectedColumn.gameObject.GetInstanceID())
                {
                    DeselectColumn();
                    SelectColumn(hitColumn);
                }
            }
            // If there is no selectedColumn, set the hitColumn to selectedColumn
            else
            {
                SelectColumn(hitColumn);
            }
        }
        // If there is no hitColumn, set selectedColumn to null
        else
        {
            hitPoint = transform.forward * 100;
            if (selectedColumn != null)
            {
                DeselectColumn();
            }
        }

        if (grabAction.GetStateDown(handType))
        {
            if (selectedColumn)
            {
                LaunchHand();
            }
            else
            {
                RetractHand(false);
            }
        }

        if (shootAction.GetStateDown(handType))
        {
            Shoot();
        }

        // Menu input when the menu is valid
        if (!menu.invalid)
        {
            if (shootAction.GetStateDown(handType))
            {
                menu.HandleTrigger();
            }
            else if (gripAction.GetStateDown(handType))
            {
                menu.HandleGripDown();
            }
        }

        UpdateConnectionPoint();
        UpdateLaser();
        UpdateConnectionLine();
        handTime += Time.deltaTime * 5f;
        grabLight.transform.position = hand.transform.position;
    }