Search Unity

Question How to detect when an object enters a socket?

Discussion in 'XR Interaction Toolkit and Input' started by AdrianCvetko, Feb 13, 2023.

  1. AdrianCvetko

    AdrianCvetko

    Joined:
    Nov 20, 2022
    Posts:
    1
    For example,
    when I put two blocks together, it would trigger an event or change the value of a boolean.
     
  2. gPerry

    gPerry

    Joined:
    Nov 27, 2013
    Posts:
    21
    You can subscribe to the Select event on the XR Socket Interactor. This is triggered when a Grabbable locks on to a Socket. Whichever object is going to be reacting to this event will need to be dragged onto the event as shown here:

    upload_2023-2-17_10-37-0.png

    In this example, I am changing the material of the Grab Interactable at the moment that it locks onto the socket. Note: this would only work with a single grabbable and a single socket. A more robust system would be needed if you have multiple instances.