Forum Discussion
Hanabear
6 years agoProtege
Hand Tracking Button Trigger Zone
Try to use the button prefab "NearFieldButton" from the new oculus integration V12.0 package. Problem is the "Interactable State Changed(InteractableStateArgs)" in Button Control panel can be triggered by all three collider zones(Proximity, Contact, Action), whichever touched first. Anyone knows how to trigger the event on Action zone only? Thanks in advance!
12 Replies
- cazforshortExpert ProtegeCould you just make the action zone bigger then the other zones or shrink the other zones down?
Theres a bug with the Ray casting though where proximity doesn't work. Shrinking it down will only fix the poking tool. - QuacklinMemberI recommend a helper script to split these eventsusing System.Collections;using System.Collections.Generic;using UnityEngine;using OculusSampleFramework;using UnityEngine.Events;public class ButtonListener : MonoBehaviour{public UnityEvent proximityEvent;public UnityEvent contactEvent;public UnityEvent actionEvent;public UnityEvent defaultEvent;// Start is called before the first frame updatevoid Start(){GetComponent<ButtonController>().InteractableStateChanged.AddListener(InitiateEvent);}void InitiateEvent(InteractableStateArgs state){if (state.NewInteractableState == InteractableState.ProximityState)proximityEvent.Invoke();else if (state.NewInteractableState == InteractableState.ContactState)contactEvent.Invoke();else if (state.NewInteractableState == InteractableState.ActionState)actionEvent.Invoke();elsedefaultEvent.Invoke();}// Update is called once per framevoid Update(){}}
- HanabearProtegeHi Quacklin, Thanks a lot for the detailed solution! It works perfectly! BTW, do you have any suggestion of how to add the grab function?
- QuacklinMemberI'm struggling with the same question :'(
The same with getting the bone gameobjects to link my custom collier. I thought that would be more easy to get a grab function. - QuacklinMemberOkay got it.
The script Hand on the spawned object HandRight and HandLeft have a function called "PinchStrength" with a Enumerator for "Index, Middle, Ring, Pinky and Max( haven't figured out what max does). They return a value between 0 and 1 when the get closer to the thumb.
I just used that to trigger an event when at least two values are 1 then grabbing is active. Everything less is release. - HanabearProtegeDo you mean the section in hand.cs?
- QuacklinMemberI think so. Unfortunately i'm not a programmer and using visual scripting to get anything to work.
- HanabearProtegeUnfortunately me neither, :D what's this visual scripting tool you are using?
- QuacklinMemberIt's called Bolt
- HanabearProtegeGot it. Thanks! Let me check it out.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 9 months ago