Esempio n. 1
0
    void Update()
    {
        bool        gripDown = false;
        InputDevice hand     = InputDevices.GetDeviceAtXRNode(handType);

        hand.TryGetFeatureValue(CommonUsages.gripButton, out gripDown);

        // 1.
        if (gripDown)
        {
            // 2.
            Collider[] overlaps = Physics.OverlapSphere(transform.position, 0.2f);

            foreach (Collider c in overlaps)
            {
                GameObject other = c.gameObject;

                // 3.
                int grabbableLayerIndex = LayerMask.NameToLayer("Grabbable");
                if (other.layer == grabbableLayerIndex)
                {
                    ControllerHaptics haptics = GetComponentInParent <ControllerHaptics>();
                    if (haptics)
                    {
                        haptics.HapticEvent();
                    }
                    other.transform.SetParent(transform);
                }
            }
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter(Collider other)
    {
        // 1. Generate haptic event
        ControllerHaptics haptics = GetComponentInParent <ControllerHaptics>();

        if (haptics)
        {
            haptics.HapticEvent();
        }
        if (gameManager)
        {
            gameManager.GetComponent <GameManager>().score += 100;
        }
        SplitMesh(other.gameObject);
        Destroy(other.gameObject);
    }
Esempio n. 3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == transform.tag)
        {
            manager.increaseScore();
            manager.hitSound();
            ControllerHaptics haptics = GetComponentInParent <ControllerHaptics>();
            if (haptics)
            {
                haptics.HapticEvent();
            }

            SplitMesh(other.gameObject);
            Destroy(other.gameObject);
        }
    }