Search Unity

Question GrabInteratable drops just on SocketInteractor

Discussion in 'XR Interaction Toolkit and Input' started by PuLieNDo, Jan 13, 2022.

  1. PuLieNDo

    PuLieNDo

    Joined:
    Sep 5, 2014
    Posts:
    5
    I can't find a good way to achieve a GrabInteractable that stays attached to the Controller on selected until user presses Grip again inside a SocketInteractor.

    Using Sticky/Toggle behaviours in XRBaseControllerInteractor helps getting interactable attached to the controller while not pressing grip button but when the grip button is pressed again, the GrabInteractable object falls to the ground or stays in the air acording to its rigidbody parameters.

    Any ideas?

    Thanks
     
  2. RoryS

    RoryS

    Joined:
    Jan 11, 2020
    Posts:
    6
    I am not sure if this is the correct approach, but I'm using this and it seems to work. Basically I Inherit from InteractionManager.cs and override this method:

    Code (CSharp):
    1. protected override void SelectExit(IXRSelectInteractor interactor, IXRSelectInteractable interactable, SelectExitEventArgs args)
    2.         {
    3.             if (!_clearToDrop)
    4.             {
    5.                 return;
    6.             }
    7.             base.SelectExit(interactor, interactable, args);
    8.         }
    Then I use the HoverEnter and HoverExit events on the socket to turn _clearToDrop on and off. That way you can only drop a grabbable inside a socket. The Select Action Trigger on my Direct Interactor is set to State Change.
    You can restrict this behaviour to certain objects by having a regular Interaction Manager on the scene for the objects that you want to behave normally.

    Again, this is what I´ve done with my limited knowledge, I dont know if its the correct way to do it. I would appreciate if someone more knowledgeable helps us out :D