Forum Discussion
uncle_hunty
1 year agoProtege
Interaction SDK: How do I disable a grabbable??
Man, there are so many absolutely basic questions like this that aren't answered anywhere. It boggles my mind.
Anyway, in the Meta XR Interaction SDK, how to do I turn off the "grabbability" on a grabbable? Like, if the player puts a grabbable peg in a hole, and I want to prevent them from taking it back out, how do I make it so they can't grab it anymore?
I figured it out.
I just had the disable / enable the "HandGrabInteractable" component on the grabbable, and that took care of it.
3 Replies
Replies have been turned off for this discussion
- MetaStoreHelpCommunity Manager
Hi there,
Thanks for posting into our forum. We can see you're having some problems in Meta XR, and we'd love to point you in the direction of more information! You can find more resources and information to solve problems on our developer's support page.
Have a great day!
- LeftoverAtomsExplorer
I felt the exact same way so here is a hacky script that solved my problem!
Implement IGameObjectFilter on a MonoBehaviour. Add the filter component on the same object as each snap interactable/interactor. In the optionals section, reference the filter in each interactable/interactor filter.using Oculus.Interaction; using UnityEngine; /// <summary> /// Add this component to snap interactable/interactors then apply the filter to every interactable/interactor part of said object for this to work correctly! /// </summary> public sealed class LockFilter : MonoBehaviour, IGameObjectFilter { public bool IsLocked => m_isLocked; public bool IsUnlocked => !m_isLocked; [SerializeField] private bool m_isLocked; private SnapInteractable m_snapInteractable; public void Lock() { m_isLocked = true; Refresh(); } public void Unlock() { m_isLocked = false; Refresh(); } public bool Filter(GameObject obj) { return IsUnlocked; } private void Awake() { m_snapInteractable = GetComponent<SnapInteractable>(); } private void OnValidate() { Refresh(); } private void Refresh() { // Applied to an interactor, do nothing. if (m_snapInteractable == null) { return; } foreach (SnapInteractor interactor in m_snapInteractable.SelectingInteractorViews) { bool hasFilter = interactor.TryGetComponent(out LockFilter filter); if (!hasFilter) { Debug.LogError($"You forgot to add '{nameof(LockFilter)}' next to the '{nameof(SnapInteractor)}'!"); continue; } switch (IsLocked) { case true: filter.Lock(); break; case false: filter.Unlock(); break; } } } } - uncle_huntyProtege
I figured it out.
I just had the disable / enable the "HandGrabInteractable" component on the grabbable, and that took care of it.
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
- 10 months ago
- 2 years ago