How do I force grab with Meta Quest SDK?

Hello guys,

I am using Meta Quest SDK with samples to develop a game. Grabbing is an understandable concept with samples, but I need to hold an object in my game constantly. Not by pressing grab buttons, but it has to always grab an object without pressing anything. How do I achieve this?

Pursuing a similar problem but I got an answer or at least a lead releated to your question. Write a script that inherits from your desired interactor and add logic that prevents “ComputeShouldUnselect” from returning TRUE.

using Oculus.Interaction.HandGrab;
using UnityEngine;

public class LockableHandGrabInteractor : HandGrabInteractor
{
    bool locked = false;

    public void Lock()
    {
        if (HasSelectedInteractable)
        {
            Debug.Log($"{name}: Lock succeeded.", this);
            locked = true;
        }
        else
        {
            Debug.Log($"{name}: Lock failed. No interactable selected.", this);
        }
    }

    public void Unlock()
    {
        Debug.Log($"{name}: Unlocked.", this);
        locked = false;

        if (SelectedInteractable != null)
        {
            ForceRelease();
        }
    }

    protected override bool ComputeShouldUnselect()
    {
        if (locked)
        {
            return false;
        }
        return base.ComputeShouldUnselect();
    }
}