[Issue] GrabBegin and GrabEnd can be triggered when the GameObject is set to active false

When I put a Grabbable Object near hand and set it to Active False, I can still grab it and will trigger GrabBegin and GrabEnd in NRGrabbableObjects, it that a Bug or a Feature?

My current solution is:
///

Grab begin.
/// The grabber.
public void GrabBegin(NRGrabber grabber)
{
if (IsBeingGrabbed || grabber == null)
return;
gameObject.GetComponent().isKinematic = true;
Grabber = grabber;
if (m_OnGrabBegan != null)
{
m_OnGrabBegan();
}

        if(gameObject.activeSelf)
        {
            SendMessageUpwards("StartGrab");
        }
    }

    /// <summary> Grab end. </summary>
    public void GrabEnd()
    {
        m_AttachedRigidbody.isKinematic = m_OriginRigidbodyKinematic;
        Grabber = null;
        if (m_OnGrabEnded != null)
        {
            m_OnGrabEnded();  
        }

        if (gameObject.activeSelf)
        {
            Invoke("SendStopGrabMessage", 0.5f);
        }
    }

Hi Lik,
We’ve tried your test process “put a Grabbable Object near hand and set it to Active False”, but we didn’t reproduce this issue, could you please describe it in more detail? It would be better to have a video that shows what goes wrong. For example, add some logs (Grab begin/end) in the scene, and record this phenomenon.

I record a video here:

My Setps are:

  1. Add Debug.log in NRGrabbableObject(Script)
  2. In this video, when I click the object, The grabbable object will be set active true and move to a certain position. After that, users can grab them.
  3. Then when the hand turns into ‘Victory’, user can delete exhibits by clicking them. One thing to notice is that the position of the exhibit didn’t change after ‘deleted’, I only set it to active false.
  4. The issue appears when hand grab the ‘Active false’ Object. Only the next time when I grab at position where the ‘Deleted Exhibit’ exists, the GrabStart and GrabEnd will be triggered.

Thanks for your detailed information and video, we know the problem now. And we’ll release this fix in the next version of NRSDK.
To solve this problem quickly, you can manually add a line of code to the following script yourself.
image

1 Like