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); } } } }
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); }
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); } }