Search Unity

(XR Interaction ToolKit) Socket Interactor not working, help!

Discussion in 'VR' started by supermrutah, Sep 5, 2020.

  1. supermrutah

    supermrutah

    Joined:
    Aug 29, 2020
    Posts:
    6
    Hi, all. I am new to Unity/game development. I started learning Unity a week ago and followed Valem and Andrew's youtube channels. I did a few small projects and everything turned out quite smoothly until last night. I was following VR with Andrew to do a Bow and Arrow in VR:
    . I downloaded his Git repo as template and built upon it (the repo contains a scene already). After following the videos bow and arrow worked as expected. So I made a package out of it and tried to import to use it in another scene where I already set up environment with more objects to play with.
    However, after import and use the prefab (bow/arrows/quiver) it simply refused to work! The quiver won't show up with an arrow (the quiver uses a Socket Interactor to spawn arrow and hold on to it). I then found out the issue was due to Socket Interactor from XR Interaction ToolKit. It is supposed to hold on to the interactable object but actually in my scene it didn't! I tried Andrew's tutorial scene again everything simply worked fine. I compared the setting and codes line by line they are identical (of course I exported and imported, nothing should have changed).
    I then created a simple sphere as Socket Interactor in my scene; it simply did NOT work. The interactable will go right through. I then created a simple sphere as Socket Interactor in Andrew't tutorial scene and again it worked just fine.
    I tried a few different version of Unity and everything is the same: I setup a simple sphere with Socket Interactor but it will NOT grab any object from the controller.
    It has been so puzzling to me... Valem also had a video about Socket Interactor and it should work but just not for my scenes...
    Anyone has any suggestions where I should look next? I feel I must be making a stupid but small mistake somewhere...
    Thanks!
    btw, I am using a Oculus quest on a macbook for development.
     
    Last edited: Sep 5, 2020
  2. Kennl66

    Kennl66

    Joined:
    Jun 26, 2020
    Posts:
    3
    i have the same problem, i'm also following Valem socket interactor tutorial. I'm using Unity 2019.4.1f1 and the socket interactor is not working. the tutorial is easy, create a sphere object and add sphere collider(set to trigger) and XR Socket interactor component to it and it's supposed to work but when i put anything it just falls and it's not grabbed. let me know if you find a fix.
     
  3. supermrutah

    supermrutah

    Joined:
    Aug 29, 2020
    Posts:
    6
    Holy moly, after a whole day try all kinds of possible fixes I finally figured out. Glad VR with Andrew's tutorial project is working and I literally compare with my project's code/config/setting with his line by line. Eventually I figured out that, it is the freaking Universal Rendering Pipeline package!!! My project was created using URP because I am new and URP sounds to be a cool idea. But the tutorial one certainly didn't use it and it worked just fine from the beginning; while mine gave me headache from the very beginning. I will never thought of this rendering pipeline will affect the seemingly totally related Socket Interactor!! But it does in my case. After removing URP from the package manager everything just started to work like a charm!
    @Kennl66 I am >90% certain this is the source of your problem! Please let me know if this fixes your headache!
     
  4. Kennl66

    Kennl66

    Joined:
    Jun 26, 2020
    Posts:
    3
    Here is the fix!! So happy it works with URP now. Someone from the comments section on Vallem's drop zone video mentioned the bug and he fixed the XR Socket Interactable script (lines 74-88). I copied it over and it works. (btw remove comments /* */ idk why he added those). thanks for your help too, i was about to remove URP from my project.



    xrsocketinteractorfix.JPG
     
    Last edited: Sep 6, 2020
  5. supermrutah

    supermrutah

    Joined:
    Aug 29, 2020
    Posts:
    6
    Thanks! This is the fix! Deleting URP works but isn't ideal as it messes up a lot of shaders.
    Apparently Unity devs forgot to change this line of code. They are still trying to find and use Standard pipeline. With this fix it will find and use URP/Lit and everything works as expected.
    btw, any way to notify Unity dev team about this bug and fix? Ultimately they need to be aware of the bug and add this fix into their official package.
     
  6. Kennl66

    Kennl66

    Joined:
    Jun 26, 2020
    Posts:
    3
    Hey were you able to finish VR Andrew's Bow and Arrow tutorial? No issues on URP? I finished it but there are issues like it only grabs the first arrow and if I put a different arrow it will not take it, only the first arrow. It could be the prefab i got from his github is getting garbled, the bow prefab doesn't have a notch like in his video.
     
  7. VeryKnightley

    VeryKnightley

    Joined:
    Feb 27, 2013
    Posts:
    1
    For some reason, replacing the code as @Kennl66 suggested doesn't stick.
    Unity keeps updating the file every time I build, so it overwrites the changes for some reason.

    Has anyone figured anything out that doesn't toss out URP?
    At this point, I would hate to remove all the shaders I made just to have basic functionality in VR..
     
  8. supermrutah

    supermrutah

    Joined:
    Aug 29, 2020
    Posts:
    6
    His code has a bug in it (I haven't had time to debug yet). So you have to grab next arrow from the "quiver". The new arrow from the quiver will work properly. However, I found out that if you grab from the middle of air (not from the quiver), one arrow will be spawned (I believe it is the previous arrow, note he has this previousArrow variable in his code) but it won't snap into the bow and won't work.
    I imported to another URP project and it worked the same way.
     
  9. supermrutah

    supermrutah

    Joined:
    Aug 29, 2020
    Posts:
    6
    yes you need to copy the XR interaction toolkit files out from cache to packages folder (go to the project folder in your computer file system and do the copy). Once you do that the changes will stay.
     
  10. NickMickU

    NickMickU

    Joined:
    Dec 27, 2016
    Posts:
    16
    Hello to everyone. I'm using XRSocketInteractor in my project (with URP) and it's work without any problems. But when I build the project and test the build, the sockets in the scene is not working! Is it a common problem? Do you have the same problem? Thank you
     
  11. Fabfab2

    Fabfab2

    Joined:
    Jan 31, 2022
    Posts:
    1
    You can just select a Material in "Hover Mesh Material". Then it works without changing the code.
     
  12. qarabakh20

    qarabakh20

    Joined:
    Oct 14, 2022
    Posts:
    1
    Hey! I solved the problem by checking the "Is Trigger" box in socket interactor's collider. In my case it was a sphere collider for the gun. Wish nice and productive work!