How to use VR Sockets (and XR Interaction Toolkit) in Unity 2021.2

Sdílet
Vložit
  • čas přidán 20. 06. 2024
  • Sockets are one of the most powerful components in your VR game dev arsenal. The holographic input in VR and the item snapping into its place are immensely satisfying. In the Unity XR tutorial, I walk you through setting up a project in Unity 2021.2 when you can't find the XR Interaction Toolkit and show you how to use sockets! Enjoy!
    📺 Watch Next: • What Do I Need to Beco...
    🥽 Enroll in the (now FREE) VR Creator Academy: skool.com/vrcreatoracademy
    ⌚ Timestamps
    0:00 Intro
    0:32 How to set up a VR Project in Unity 2021.2
    4:09 How to setup XR Interaction Toolkit
    9:16 How to use Sockets
    #vr #sockets #unity

Komentáře • 107

  • @JustinPBarnett
    @JustinPBarnett  Před 2 lety +6

    Download the Project (for FREE): www.vrcreators.io/codedownloads

  • @tatepayton7368
    @tatepayton7368 Před 2 lety +8

    This is just what I was waiting for! A simple way to make things like backpacks and stuff with sockets. Thank you so much for helping out the VR community!

  • @FusedVR
    @FusedVR Před 2 lety +4

    Super comprehensive. Very nicely done!

  • @tientam779
    @tientam779 Před 2 lety +1

    Once agin, great and simple to understand tutorial. I like that you're always checking up on XR toolkit from Unity and making new tutorials about it, allows anyone new to just jump right in and get started with those tool!

  • @shayaltshue1791
    @shayaltshue1791 Před 2 lety +1

    Insanely useful tutorial. Thanks Justin!!

  • @thaFoxy
    @thaFoxy Před rokem +1

    great Patreon! it has everything I needed.

  • @SimpleDays101
    @SimpleDays101 Před 2 lety

    Once again, I must proclaim that you are, in fact, the MVP. Thanks for the great tutorials!

  • @HenshinAsset
    @HenshinAsset Před 2 lety +1

    Thank god you did this tutorial. I would have problems this Sunday 😆

  • @Jason-eo7xo
    @Jason-eo7xo Před 2 lety +1

    so awesome!

  • @4per8
    @4per8 Před rokem +1

    immana use this for a debug menu in the game im working on, might be cool

  • @torstenknodt6866
    @torstenknodt6866 Před 7 měsíci

    Great video, thanks! Is there a way to check dynamically whether a socket interactable could really be dropped on a socket interactor or there is some use-case specific condition which does not allow it?

  • @ivani5543
    @ivani5543 Před 10 měsíci

    Thank you for your wonderful tutorial. If using xrit to splice objects, similar to LEGO, how can they be connected one by one? Do you have any good suggestions?

  • @catalinpop342
    @catalinpop342 Před 2 lety +1

    The timing on this video couldn't have been better. Ran into the missing XR Interaction Toolkit issue yesterday when I updated to 2021.2.6f1 and today I decided to check out my go-to Unity VR resource on CZcams...and what do you know? :)) Massive thanks for all the content, would take me forever to figure this stuff out on my own.

  • @Ctorresification
    @Ctorresification Před rokem

    Great tutorial! Is there any way to make it so the player has to place the interactable object into the socket? I have a socket attached to my players finger for attaching rings and I can pick up the ring with one hand and put it onto the finger of the other hand just fine, but I can also just move my hand over a ring sitting on a table and it will snap to the socket automatically. I want the player to manually drop the ring onto the finger.

  • @Riprog
    @Riprog Před 2 lety +3

    Hey Justin! Love your content, keep it up! I have an issue with using XR Socket Interactors in multiplayer applications using Photon (PUN 2), so far I've gotten no response on the Unity forums. The problem I face is that if a player puts an object in a socket and then grabs it again, the item remains in the socket for other players (not seeing that a player has a grabable in hand). The item has a photon view component on it and also a photon rigidbody view component, I suppose you need to add some component to the socket interactor? Thanks in advance!

    • @user-yn1sy9bt4w
      @user-yn1sy9bt4w Před 2 lety +1

      I have the same problem, just yesterday I saw your post on the Unity forum :). Justin, if you can give any advice would be very grateful too!

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +2

      So my initial guess is that is has something to do with parenting the object. Maybe try adding a script to have it follow the socket attach point every frame instead of parenting it. Just a guess though.

    • @petitwhito3196
      @petitwhito3196 Před 2 lety

      Hi ! I have the same issue, have you found the solution to the problem ?

  • @Calactic
    @Calactic Před rokem +2

    Thanks for this, helped a tonne. I'm just wondering, how would you go about making items being able to stack up on each other? Our game is a survival/horror game and we want players able to put more than one of the same item into a hotbar, which is a sphere socket interactor. Our game takes heavy inspiration from "A Township Tale" if you're familiar.

    • @firizz
      @firizz Před rokem

      have you found the answer? plese let me know if you do

  • @djmedina50
    @djmedina50 Před rokem

    Hello Justin, I like so much your videos. I have one question. I've followed your tutorial to try to do an inventory but at the moment I hide de canvas all the items that I have shocked falls down. What can I do to make the Items be hiden with the canvas and showed again. The inventory is a canvas with Slots that can be showed and hided pressing the button X of the left controler in Oculus quest 2. Thanks and best regards.

  • @bones99999
    @bones99999 Před 2 lety +2

    Very nice tutorial. Thanks. My new favorite channel.
    Could you do a tutorial on Hand interaction with colliders on say a desk or wall?
    Specifically, where if you push the controller through the desk, that the hand stays on the desk until you bring the controller back to the hand position and it will track with the controller again.
    Or is this built-in to the tool kit?
    I know some VR interaction tool kits have this feature.

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      It's not built into the toolkit, but I have made a video about physics hands! Check it out: czcams.com/video/RwGIyRy-Lss/video.html

    • @bones99999
      @bones99999 Před 2 lety +1

      @@JustinPBarnett cheers. I saw that after I wrote the message. Thanks

  • @_Garm_
    @_Garm_ Před 2 lety +1

    Hi Justin, great tutorial! would you be able to show how to do power cables with the Obi Rope addon like plug in and un plug :)

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +2

      That’d be cool! I haven’t used it but I’ll look into it

  • @BlackDev
    @BlackDev Před 2 lety +1

    I love your vids self taught inspiring game dev have been binge watching your vid and using them as projects but i cant figure out where im going wroong here my line visiuals arent tracking they just go up and down

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      Thanks! Join the discord and we can help you out!

  • @cryptopedia7257
    @cryptopedia7257 Před 2 lety +1

    hey justin really love the conent. can you make a video on unity vs unreal engine 5 for vr development !!!!!

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      Yea! I actually dabbled around in unreal for a bit before coming over to unity. I talked about it a bit in my “What you need to start VR” video

  • @Ollie_sm
    @Ollie_sm Před 2 lety +5

    could you do a tutorial on how to make it possible to climb and glide and even an accurate gliding mode where you can steer up and down using your hands

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +4

      Ooo that’s a cool idea! I’ll add that to my list!

    • @Ollie_sm
      @Ollie_sm Před 2 lety +2

      @@JustinPBarnett thank you so much!

    • @Ollie_sm
      @Ollie_sm Před 2 lety

      @@JustinPBarnett mechanics similar to this would be great czcams.com/video/jEiKb2-DdDQ/video.html much better than gliding in most vr games

  • @andreramiro732
    @andreramiro732 Před rokem

    How can i do this with the Oculus Integration (OVR)?

  • @kathy02158
    @kathy02158 Před rokem +1

    who can tell me if i want use xr sockets apply in slot and become 2d image ,how should i do?

  • @infectedgoat99
    @infectedgoat99 Před 2 lety +8

    How did you figure all this out on your own? Incredible video, super helpful. ALSO for anyone struggling with getting the hammer to face the right direction when holding, make sure in the XR Grab Interactable script that you drag your empty game object "Attach Point" onto the "Attach Transform" otherwise the object wont use your attach points!

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +2

      Lots of testing and just playing around in Unity 😜 and thanks for the tip!

    • @V-ROCstudios
      @V-ROCstudios Před 2 lety +1

      Thanks. I kept thinking I needed to rotate a component.

    • @k1ng401
      @k1ng401 Před 2 lety +2

      haha just worked this out myself and then thought "someone else must have had this problem..."

    • @tommedenney
      @tommedenney Před rokem

      Thank you soooo much omg tried to figure this out for an hour and a half before coming here

  • @patty__
    @patty__ Před 2 lety +1

    hey, great video. just wanted to ask if i should continue with unity 2020 or if you think i should use 2021 instead? i'm only up to importing hands in 2020 so it wouldn't waste much time to start the 2021 version.

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      If you're building a game to release go with the latest 2020.x LTS version, but if you're just learning then I'd recommend using the latest non-beta version! Does that make sense?

    • @patty__
      @patty__ Před 2 lety +1

      @@JustinPBarnett yeah that makes sense, thanks. i do want to make a small first game so i'll stick with 2020, thanks!

  • @doktor1350
    @doktor1350 Před rokem

    Can I use XR Interaction Toolkit with SteamVR plugin hands?

  • @wisdomkhan
    @wisdomkhan Před 4 měsíci

    Any idea how to make a Lego VR game?

  • @k1ng401
    @k1ng401 Před 2 lety +1

    How do we make the hammer and shield collide with each other when held? or is that not possible. I see they collide with the world and they collide with each other when not held but I can't bang them together while holding them. I don't know if I ever will want to but it might be handy to know

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      Change the grab interactable component grab type from instantanious to velocity tracking

  • @jaimejia86
    @jaimejia86 Před 2 lety +1

    Hi Justin, Im using the Oculus interaction (OVR) but i can find any snap or socket script, please help me

  • @dracula9202
    @dracula9202 Před 2 lety +3

    Impressive! Thanks for sharing!
    I wonder if there is a workaround so that only objects that are being grabbed atm can be selected in the socket. I already tried to play around with some things in the public override bool CanSelect(XRBaseInteractable interactable) interactable.isSelected.. but nothing seems to work xD Thanks in advance if anyone has a hint^^

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      I was actually playing around with that today and couldn’t find a solution for that either 🤔

    • @Acilianus
      @Acilianus Před 2 lety +2

      I know it has been 4 weeks now, but It was tricky and I found a (mostly satisfactory) solution so posting it here for you in case it is still relevant. What I did is I switched the layermask on the interactable when the interactable hovers over the socket (OnHoverEnter interaction event) to a layer which can not interact with the socket, on the condition that an XRDirectInteractor is not currently selecting the interactable.
      The tricky part here is that you have to switch back to the originla layermask. First my intuition was to do it on the OnHoverExit event, but since the interactable was moved to another interaction layer, the socket was not detecting events on it anymore... So instead I implemented a coroutine which resets the layer mask on the interactable if the interactable is selected, or moves away a certain distance from the socket. This mostly works well, the only hiccup is that when the (ungrabbed) interactable falls into the socket, it still stops for a second before falling through it. However, the socket will not pick up the interactable even if the interactor rests right on top of it. Here is the code for reference (the disableInteractor method is bound to the OnHoverEnter event of the socket. Note that interaction layer numbering starts from 1 not 0. Also note that when the interactable hovers above the socket it already counts as selected. ):
      // Disable the interactable if it is not grabbed when placed into the socket (e.g. it conincidentally falls/bumps in it)
      public void disableInteractor( HoverEnterEventArgs eventargs )
      {
      XRGrabInteractable interactable = (XRGrabInteractable) eventargs.interactableObject;
      if ( interactable.interactorsSelecting[0].GetType() != typeof( XRDirectInteractor ) )
      {
      //interactable.GetComponent( ).enabled = false;
      interactable.interactionLayers = 2;
      StartCoroutine( reEnableInteractor( interactable, interactable.interactorsSelecting[0] ) );
      };
      }
      // Reenable the interactor after an accidental fall/bump into the socket
      private IEnumerator reEnableInteractor( XRGrabInteractable interactable, IXRSelectInteractor interactor )
      {
      while ( Vector3.Distance( interactable.gameObject.transform.position, interactor.transform.position ) < 0.2f )
      {
      if ( interactable.isSelected && interactable.interactorsSelecting[0].GetType( ) == typeof( XRBaseInteractor ) )
      {
      interactable.interactionLayers = 1;
      break;
      }
      else
      {
      yield return new WaitForSeconds( 0.1f );
      }
      }
      interactable.interactionLayers = 1;
      }
      Hope this might help some people.

  • @kwani_
    @kwani_ Před rokem

    Everytime i press play my hands are not attached, it just stay where it is and I can't see them, anyone knows how to fix this please ?

  • @trumancoburn3335
    @trumancoburn3335 Před 2 lety +1

    Hey quick question, is there anyway to get a held input for my joystick? I'm trying to make a sprint system but I cant get an unpressed thing back from it, so I cant make the speed go back to the original when you unpress the joystick.

  • @1998natan
    @1998natan Před 2 lety +1

    Very nice tutorial. But i don't know how to launch my project on quest 2. Do i need to do something special?
    Cheers

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      Like build your project to the quest or just run it in play mode?

    • @1998natan
      @1998natan Před 2 lety +1

      @@JustinPBarnett Thanks for answering! Got help on your discord. I had to disable air link and then plug in cable and enable on quest.
      👍💪

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      @@1998natan awesome!!

  • @tylerjones9197
    @tylerjones9197 Před rokem +1

    Heads up, Toolkit is spelled wrong in your title. It says tookit. Great tutorial keep em up!!

  • @HenshinAsset
    @HenshinAsset Před 2 lety +2

    OMG, can't believe they changed it all again 😫

  • @thegamingcoder4789
    @thegamingcoder4789 Před 2 lety

    how do you use the socket interactor to trigger code events

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      In the inspector there should be interaction events you can attach scripts to

  • @Magiak
    @Magiak Před 2 lety +1

    Hello Justin. Could you please help me find out why I can see only black screen in my Oculus Quest 2? I step by step followed the first section 'How to set up a VR project in Unity 2021.2'. of video, Then I switched the platform to Android, selected device and pressed 'Build and run'. It created the apk and uploaded it to the quest but only thing I can see on my Oculus is black screen. Could you please help me what to do? I tried older Unity 2019, 2020 and it's OK but I would like to use Unity 2021. Thank you for awesome video!

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      Hmmm maybe ask in the Discord. May need some screenshots or more specific details to help fix

    • @Magiak
      @Magiak Před 2 lety +1

      @@JustinPBarnett Do you have any example project in Unity 2021 configured for Oculus Quest I could try to run?

  • @bhargavgaurav9870
    @bhargavgaurav9870 Před rokem

    Xr toolkit inputfield active perform tha meta quest pro

  • @k1ng401
    @k1ng401 Před 2 lety +1

    Did you miss a step? Were you supposed to make the Attach Points selected in the Attach Transform selection? Until I did that, it was ignoring my Attach Points completely and the hammer was facing the wrong way, the shield was being held right in the centre

  • @gnomge
    @gnomge Před 2 lety +2

    ayo hold on, letss goo, exactly what i needed. btw i need to add a simple bean to act as the character, like follow the xr rig, cuz when i put it under the xr rig it doesnt follow the camera movement, but when i move it under the camera, it breakdances on me. oh and also how the hell do i stop my character from being able to fly when holding an interactable
    ways to recreate: create basic xr rig (action based) create an interactable, hold the interactable under the player.

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      You can checkout my VR movement video for getting the collider to follow your camera. And in order to prevent held things from interacting you should set them to an “interactable” layer and set the player to a “player” layer and then in your project settings > physics make sure in the grid that the checkbox between the layers is unchecked so they don’t interact

    • @gnomge
      @gnomge Před 2 lety +1

      @@JustinPBarnett thanks a lot! also does ur video include adding a visual character to the xr rig? cuz my project is a vr shooter and it needs the character to not only to have a body, but the body to have a collider. so how the hell do i set up the character model (i only need it to be a bean) to the xr rig?

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      @@gnomge I do have another video about that! Inverse kinematics

  • @alejandrodelgado74
    @alejandrodelgado74 Před 2 lety +1

    Awesome thanks so much….. unity should by default setup your scene….

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      Yea that'd be nice. There is a VR template, but it's not really that great

  • @christopherarendt3531
    @christopherarendt3531 Před 2 lety

    There is no Default Input Actions under XR Interaction Toolkit Samples

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      It's changed to another name, but still in the same place

  • @leventebotos6927
    @leventebotos6927 Před 2 lety +1

    Hi guys! I want to ask that how can i address an xr origin in code? Sorry if it's a stupid question but i can't find a solution on the internet.

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      It's the "XROrigin" class!

    • @leventebotos6927
      @leventebotos6927 Před 2 lety +1

      @@JustinPBarnett Hey Justin!
      Could you explain this please?

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      @@leventebotos6927 join the discord and we can answer more detailed

  • @k1ng401
    @k1ng401 Před 2 lety +1

    Only renders in the Left eye. Did I accidently click something I shouldn't have?

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      Try going to project settings > OpenXR > and swap render mode to multi-pass

    • @k1ng401
      @k1ng401 Před 2 lety +1

      @@JustinPBarnett Yep! That fixed it. NOTE i have both the PC and Android OpenXR setting and first I tried it on the Android part and it made no difference so I did it on the PC setting part and it worked. So basically it's the PC Settings that matter when streaming from the PC to the headset and the Android if you Build and send the file to the headset to play it there? is that correct?

    • @k1ng401
      @k1ng401 Před 2 lety

      @@JustinPBarnett as a side benefit I now know how to simulate a pirate player character with a patch on his right eye if I ever create a swashbuckling VR game 😁

  • @hynesie11
    @hynesie11 Před 2 lety

    damn i thought this was gonna be about web sockets :(

  • @franciscoflor6572
    @franciscoflor6572 Před 2 lety +1

    I followed all these steps yet interaction toolkit does not come up

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      You typed it in correctly to the package manager?

    • @OTAKUBLOCKU
      @OTAKUBLOCKU Před 2 lety +1

      @@JustinPBarnett Yes even re did it a couple times too. And tried different versions of Unity. How is that possible?

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety

      @@OTAKUBLOCKU Strange.... does it show up in 2020 for you if you enable pre-release packages?

    • @OTAKUBLOCKU
      @OTAKUBLOCKU Před 2 lety

      @@JustinPBarnett yeah that’s what’s so weird about it. I do have an “error refreshing packages and features,see console” in the package manager.
      In console it says;
      “Cannot perform upm operation: unable to perform online search:”
      And
      “Error searching for packages”
      My wife is connected though.

    • @OTAKUBLOCKU
      @OTAKUBLOCKU Před 2 lety +1

      @@JustinPBarnett okay I figured it out I needed to create a new rule for my firewall to accept unity updates from internet. Thank you for responding.

  • @steampunkengi5805
    @steampunkengi5805 Před 2 lety

    How weird; my Socket Interaction's Hover Mesh isn't in a static location, but follows/rotates with the object I want to put in! Even more so, it's not even IN that object, it's some distance away

    • @JustinPBarnett
      @JustinPBarnett  Před 2 lety +1

      Very strange. Sometimes socket stuff has a mind of its own