Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
pranav_suresh7's avatar
2 years ago

How to know when I grab the object back from SnapInteractable componenent?

Hi, I have created a SnapInteractable gamoebject and for the SnapPoseDelegate(Which helps in placing objects in different/specific positions over a gameobject) I have implemented ISnapPoseDelegate interface . When I place the SnapInteractor to SnapInteractable gameobject UnSnapElement function is getting called after SnapElement function with a few milli seconds difference. I haven't even grabbed the gameobject back from the SnapInteractable where it was attached/snapped. Is this the common behavior ? If this is behavior it was intended to achieve then how to know when I grab the object back from the SnapInteractable Gameobject? Thanks in advance.

4 Replies

    • Big_Flex's avatar
      Big_Flex
      Meta Employee

      Hi pranav_suresh7, thanks for tagging me! The delegate is not supposed to be called right after it is placed. Could you share a video of what you're experiencing, including any logs? Could you also share your delegate code here? 

      To tell if or when the object is currently being grabbed, use an Interactable Group View component and set its Interactables list to all of the grab enable interactables (hand grab, grab or ray).

      • pranav_suresh7's avatar
        pranav_suresh7
        Protege

        Hi Big_Flex  thanks for the reply.  this is the issue https://youtu.be/zl_rwHjp-Ew. I got where the issue is coming  but I don't know which is the proper way to resolve this. In SnapInteractable-> SelectingInteractorAdded-> SnapElement function I'm marking the added Interactor position in gird as MARKED, in the DoSelectUpdate() function in SnapInteractor which calls the function (Interactable.PoseForInteractor(this, out Pose targetPose)) that calculates the position/pose for this SnapInteractor. So this function Interactable.PoseForInteractor(this, out Pose targetPose) is also called after SnapElement function where I mark the position as MARKED. Since here Interactable.PoseForInteractor(this, out Pose targetPose) if the position SnapInteractor matches this MARKED position it returns FALSE since it was already marked which makes _shouldUnselect to TRUE. I can fix this by adding some conditions but I don't know whether that is the right way. PROBLEM: I have a grid of positions, when I place the gamoebject on to grid positions I have to attach the gameobject to respective positions. If some position is marked as ALREADY ADDED  then I shouldn't attacht the gameobject towards that position. Also after it reaches the position it's size have to change accordingly with the position where it's attached.

  • Hi Big_Flex I have resolved the issue with UnSnapElement function by adding some extra checks by getting indentifier(ID) of snapinteractor and having some checks with mapped(Dictionary) positions associated with it. Now I got one more issue since I'm having so many SnapInteractors i'm disabling them based on their positions associated with my hand. But when I disable the interactors it is calling the UnSnapElement function. So in my case I can't use UnSnapElement function.