keep object in socket and disable interaction
RoxDevvv opened this issue · comments
i want to keep an object in socket and stop the user from interacting with it until a variable change (let's say after he collects some coins)
i tried to change layer mask for the object :
obj.GetComponent<XRGrabInteractable>().interactionLayers = InteractionLayerMask.GetMask("Nothing");
also I tried to set socket active to false
in both ways, the object fall down from the socket
also tried
manager.UnregisterInteractable(obj.GetComponent());
object still fall down!
it looks like the only way is to capture the pose before disabling it.
interactablePos.position = interactorPos.position;
interactablePos.rotation = interactorPos.rotation;
the best way i found is to use select entred event
create new layer mask and name it "NoUse"
public void DisableInteraction(SelectEnterEventArgs item)
{
item.interactableObject.transform.GetComponent<XRGrabInteractable>().interactionLayers = InteractionLayerMask.GetMask("NoUse");
item.interactorObject.transform.GetComponent<XRSocketInteractor>().interactionLayers = InteractionLayerMask.GetMask("NoUse");
}