Search Unity

Socket Interactor event when interactable is attached?

Discussion in 'AR/VR (XR) Discussion' started by dgoodman-icf, Feb 19, 2020.

  1. dgoodman-icf

    dgoodman-icf

    Joined:
    Jan 7, 2019
    Posts:
    36
    I can't find a way to fire events (sounds, call other methods on other objects, etc.) at the point when a grab interactable is attached to a socket. The events for the interactable are only related to that interactable. The events for the socket are only related to the socket. For example, I press and hold the trigger to grab an interactable. I hold down the trigger and walk over to the sock and hover. When the hover mesh appears, I release the trigger and the interactable snaps into position. So far so good. However, if I used any events on the interactable, those events fire independently of the socket. In other words, if I say put a script to play a sound on the interactable's OnSelectExit event, and I release the trigger before placing it into the socket, the events will fire. Also, if I wait to release the trigger when hovering over the socket attach point, the interactable will pop into place, but THAT select exit event if for the interactable, not the socket. Anyway, I've been going over the XRITK scripts and I cannot find a way to hook into this behavior. Any insights from you guys would be great!

    Edit: For now I'm going to check the interactable's collider against the socket's collider and fire the events only if they're intersecting.
     
    Last edited: Feb 19, 2020
  2. Matt_D_work

    Matt_D_work

    Unity Technologies

    Joined:
    Nov 30, 2016
    Posts:
    202
    It should give you an OnSelectEnter when an object is attached, and an OnSelectExit when removed.
     
    dgoodman-icf likes this.
  3. dgoodman-icf

    dgoodman-icf

    Joined:
    Jan 7, 2019
    Posts:
    36
    I tried that early on and it didn't work. I'll try again though in case I did something else to prevent the expected behavior. Thanks!
     
  4. dgoodman-icf

    dgoodman-icf

    Joined:
    Jan 7, 2019
    Posts:
    36
    Just tested in an new scene and you, of course, are correct. The issue was that I wasn't putting my script with calls to other actions (play a sound, open a door, etc.) directly on the Socket gameobject so the OnSelectx functions from the other game objects were being used. Guess I shouldn't code at 4am. ha

    Thanks again!