示例#1
0
    // Update is called once per frame
    void Update()
    {
        UpdateHandAnimation();

        targetDevice.TryGetFeatureValue(CommonUsages.gripButton, out bool gripButtonValue);

        targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue);
        if (Sword)
        {
            Sword.DeltaActive(gripButtonValue);
            Sword.setState(triggerValue > 0.5f);
        }

        targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonValue);  //Press A to activate sword
    }
    void Update()
    {
        if (grabber)
        {
            // to stay in users hand
            parent.gameObject.GetComponent <Rigidbody> ().isKinematic = true;

            // fixes flicking / exaggerated velocity
            if (openCheck != parent.open || grabCheck != grabber)
            {
                parent.Detach();
                parent.gameObject.transform.position = this.gameObject.transform.position;
                parent.gameObject.transform.rotation = this.gameObject.transform.rotation;
                parent.Reattach();
                openCheck = parent.open;
                grabCheck = grabber;
            }

            if (parent.open)   // to apply joint physics properly
            {
                this.gameObject.transform.position = grabber.transform.position;
                this.gameObject.transform.rotation = grabber.transform.rotation;
            }
            else     // to fixes offset when swinging
            {
                parent.gameObject.transform.position = grabber.transform.position;
                parent.gameObject.transform.rotation = grabber.transform.rotation;
            }
        }
        else
        {
            // easier pickup physics
            parent.setState(false);

            // hey gravity is a think xD
            parent.gameObject.GetComponent <Rigidbody> ().isKinematic = false;
        }
    }