Introduction to VR in Unity - PART 8 : SNAP ZONE

Поделиться
HTML-код
  • Опубликовано: 31 янв 2025

Комментарии • 117

  • @ValemVR
    @ValemVR  Год назад +1

    Hey guys ! I made an update of this series on my channel Valem tutorial that you can find here : ruclips.net/video/fM0k2n7u8sc/видео.html

  • @sotogje
    @sotogje 4 года назад +41

    You are always suprising me offering the exact tutorial I am looking for

    • @jordyatondo1004
      @jordyatondo1004 4 года назад

      Ikr, I literally needed this yesterday, lol.

  • @LivanderGamedev
    @LivanderGamedev 4 года назад +1

    This is what I've been waiting for!

  • @mironco9595
    @mironco9595 4 года назад +3

    Yay! I really like this series! Thanks for another episode

  • @riska52p
    @riska52p 4 года назад +2

    I love this series

  • @Rickmanx1972
    @Rickmanx1972 4 года назад +2

    Another excellent tutorial! And it is funny... I was about to work on creating drop zones for attaching swords and potions to a belt, but you saved me a bunch of time. Thanks again :)

  • @RigidDecay
    @RigidDecay 2 года назад

    Thank you so much! This helped me with my holsters, I love how it is extremely simple and intuitive.

  • @nein_3371
    @nein_3371 4 года назад

    i realy like how motivated you are in every video :D

  • @magnusthomsen450
    @magnusthomsen450 4 года назад +2

    Thanks Valem 😁

  • @curranh.8328
    @curranh.8328 4 года назад +1

    You are very skilled. Great tutorial! Thank you for bringing this to the masses! 😁

  • @dimashutama9378
    @dimashutama9378 2 года назад

    how TF did you not get 1M view?, this tutorial is very good and explained really well.

  • @AdrianMeredith
    @AdrianMeredith 4 года назад +6

    this is great! how about some enemies next? would like to know how to physically interact with another character with that lightsabre?

  • @meeperhere
    @meeperhere 4 года назад +3

    Valem: only uses box colliders and sphere colliders
    Mesh Collider: Am i a joke to you?

    • @PhantomWolf93
      @PhantomWolf93 4 года назад +2

      The Mesh Collider is more accurate when it comes to establishing collisions, but on the other hand it can give problems and inaccuracies when Unity has to calculate its physics. Whenever you can, use a box collider.

    • @A_C_007
      @A_C_007 4 года назад +1

      @@PhantomWolf93 I feel like whenever I have a problem with collisions being detected it is because I'm using a mesh collider, way less problems with the other types. Idk what the problem is.

    • @meeperhere
      @meeperhere 3 года назад

      A Convex Mesh Collider Will Work Though

  • @richardosborn159
    @richardosborn159 3 года назад

    thank you for this high-quality info

  • @harmonicsaurav
    @harmonicsaurav 2 года назад

    This is awesome!!

  • @JackDontLie
    @JackDontLie 4 года назад

    Thanks valem! :)

  • @MichaelSchubertPhoto
    @MichaelSchubertPhoto 4 года назад +8

    Hey Valem really enjoy your tutorial. One question considering Socket Snap Zones in XR. Is there a way that I restrict my snapping zone? So my Gun has a specific Snap zone that no other object can snap to. E.G. via a Tag. So only a Gun with a "Gun Tag" and the Snap zone with the Tag "Gun Snap" can work/snap togehter? Would be nice to have this additional info.

    • @snufkrill
      @snufkrill 3 года назад +2

      A year late but in the xr socket interactor theres a tab that says interaction layer mask, set it to the layer u want and only objects within that layer can snap into it.

  • @austinheydari1813
    @austinheydari1813 4 года назад

    keep up the good work ! thx for the tutorial series 👍🙂🙂

  • @Dunzz100
    @Dunzz100 4 года назад +1

    Gracias c: tus videos son de mucha ayuda.

  • @adgjl822
    @adgjl822 4 года назад +6

    Can you do a video like "how to make a body in VR" but with Unity XR now?

  • @samcasters
    @samcasters 4 года назад +8

    Woudnt you be able to put anithing 9n your head is there a way to make it so you kan only put things on your head with a specific tag

    • @charlottedegooijer4536
      @charlottedegooijer4536 3 года назад +2

      A bit late, but for anyone still looking for this. Check out his second tutorial on creating a realistic gun, there he gives a script to extend the socket interactor with a tag.

    • @Kazumo
      @Kazumo 3 года назад

      @@charlottedegooijer4536 Thank you!

  • @sambrown2427
    @sambrown2427 4 года назад +3

    Thanks again for the tutorials. I would love to learn how to make the snapzones not scoop up items I pass by. I only want items I place in them via hover to get grabbed. I've tried some solutions with no success yet.

  • @blissofkundalini
    @blissofkundalini 4 года назад

    Another mind-blow! Haha!

  • @stevencraft7144
    @stevencraft7144 3 года назад +1

    It wasn't entirely clear to me what the follow math was doing, but to me, if you want something which basically follows your position and direction you are facing, and offsets but only taking into account Y rotation, I'd do something like:
    transform.rotation = Quaternion.Euler(0f, target.transform.rotation.eulerAngles.y, 0f);
    Matrix4x4 m = Matrix4x4.TRS(target.transform.position, transform.rotation, target.transform.localScale);
    transform.position = m.MultiplyPoint(offset);
    This seemed to work for me (it gave me inventory slots which were always below my head, around my waist, on the left and right.

  • @MouiTV
    @MouiTV 4 года назад +1

    Great videos! It would be great if you could make a video showing how to replace the hands in steamVR into custom ones, there is very little information on how to do this and seems quite difficult!

  • @filipbursik9635
    @filipbursik9635 3 года назад

    That's great, nice tutorial!

  • @silwerifpv8395
    @silwerifpv8395 4 года назад +4

    Thank you for this excellent tutorial series! I'd like to report a bug that I found with XR Interaction Toolkit with URP on oculus go. Same issue might be with quest? XR Socket interactable is not working when project is using URP. Could you test this project on quest and see if the same bug remains?

    • @silwerifpv8395
      @silwerifpv8395 4 года назад +5

      Found the bug in XRSocketInteractor script on material creation on lines 74-88. After replacing the lines 74-88 with below code, the snap zones work on Oculus Go (possible issue on Quest too?):
      if (m_InteractableHoverMeshMaterial == null)
      {
      // create of default transparent shader
      var m_InteractableHoverMeshMaterial = new Material(Shader.Find("Universal Render Pipeline/Lit"));
      if (m_InteractableHoverMeshMaterial)
      {
      /* m_InteractableHoverMeshMaterial.SetFloat("_Mode", 2);
      m_InteractableHoverMeshMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
      m_InteractableHoverMeshMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
      m_InteractableHoverMeshMaterial.SetInt("_ZWrite", 0);
      m_InteractableHoverMeshMaterial.DisableKeyword("_ALPHATEST_ON");
      m_InteractableHoverMeshMaterial.EnableKeyword("_ALPHABLEND_ON");
      m_InteractableHoverMeshMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON");
      */
      m_InteractableHoverMeshMaterial.SetColor("_Color", new Color(0.0f, 0.0f, 1.0f, 0.6f));
      }

    • @adhochero6619
      @adhochero6619 4 года назад +1

      @@silwerifpv8395 yes this is an issue on quest if you run the game it just not there no sockets whatsoever

    • @kennl66
      @kennl66 4 года назад +1

      @@silwerifpv8395 Thank you so much, this fixed the issue with XR Socket Interactable not working with URP :)

    • @renmiao296
      @renmiao296 4 года назад +1

      I also found this issue on Oculus Quest. Thanks a ton for finding the bug and the fix! I was about to remove URP from my project but with this fix I will continue with URP!
      Also I am not sure if we need to comment out those m_InteractableHoverMeshMaterial setters (between /* and */). I left them in, only changed var m_InteractableHoverMeshMaterial = new Material(Shader.Find("Standard")); => var m_InteractableHoverMeshMaterial = new Material(Shader.Find("Universal Render Pipeline/Lit"));. Apparently Unity team forgot to change this line of code (still trying to find Standard shader). With this one line code change Socket Interactor works as expected on Oculus quest.

    • @TheRedMC
      @TheRedMC 4 года назад +1

      @@silwerifpv8395 Thanks for finding this fix, dude!

  • @AlexBrigham
    @AlexBrigham 4 года назад +1

    Hey Valem, thank you for all of the work you've done on this series. I used to make GearVR games, and took a few years off. Now getting into Quest development with the help of your tutorials.
    I was wondering if we could see how to make functions that respond to the Touch Triggers being held down. Like a gun that charges while held down, and shoots on release. It doesn't seem like there is any equivalent to "GetButtonDown(0)" for the touch controllers.
    Thanks again!

    • @spidernh
      @spidernh 4 года назад

      Yeah I wish you could just do something like "Input.GetAxis("LeftTouchControllerTrigger");"
      I just had to make my own input manager and get the variables that has for each input from other scripts.

  • @Zyymk0
    @Zyymk0 4 года назад +1

    Keep it up 😛😇

  • @MrRansuil
    @MrRansuil 3 года назад +1

    Lol, I had a cool bug where the door and drawer from the previous tutorial are grabbables, and so when I opened the drawer it would collide with the inventory dropzone that was following me around and completely break the physics!

    • @gamerpros413
      @gamerpros413 3 года назад +1

      Did you fix it? I have the same problem.

  • @doriondouglas6176
    @doriondouglas6176 4 года назад +5

    How do you make it so only one specific object can be put into a drop zone? Like with the hat, you could put anything on your head. I wanma make a key system but I dont want a gun in there. I guess I could just use a function that checks if its that exact object, but you will be able to put anything in there.

    • @Mtech7752
      @Mtech7752 4 года назад +1

      I guess you can just play with the layers. Look at the "XR Socket Interactor" component of your DropZone. You can chose the layer it is interacting with.

    • @Mtech7752
      @Mtech7752 4 года назад +3

      Okay I just did it. Follow my steps. Lets say I want to make a holster for my Lightsaber. And the light saber will be the only thing I can attach to it.
      1) Create a dropzone like in the video.
      2) Create a layer called "Light Saber Holster".
      3) In the "XR Sockets Interactor" component of your dropzone, there is a line called "Interaction Layer Mask" wich is set to "everything". Put it to "Light Saber Holster" only.
      4) Now look at your Light Saber. It has a component called "XR Grab Interactable". There is the same parameter called "Interaction Layer Mask". It is set to "everything". You will notice you can attach your LightSaber to your Holster just like that. But, we dont want any other object to be able to attach to that holster. Here is the trick. You have to change the "interaction layer mask" of every other object to uncheck the layer "Light Saber Holster" that we created.
      It is a bit long, but in the end its very effective. Because you dont have to change the layer of any of your objects, just the layer mask. If not, you wouldnt be able to grab them anymore. Tell me if you have a problem.

    • @garlicsuter
      @garlicsuter 4 года назад

      @@Mtech7752 I'm trying the route of a custom function so I can just check the tag of the object being held in the snap zone, but I can't get it to work, it just says NOT A FOX everytime even if it IS tagged as "fox":
      public void IsItAFox(Collider other)
      {
      if (other.tag == "fox")
      {
      Debug.Log("Yes, it's a fox hovering");
      }
      else
      {
      Debug.Log("NOT A FOX HOVERING");
      }

    • @doriondouglas6176
      @doriondouglas6176 2 года назад +1

      @@Mtech7752 hey just found this comment 2 years later. I appreciate you going through and doing it (youtube never gave me a notifcation so i never knew! haha) but thank you for going through the effort, it is much appreciated.

  • @devincollins4804
    @devincollins4804 4 года назад +1

    This is great! I always check my feed for when you release new videos! Is there a way to connect this snap zone functionality to a trigger? Say, inserting a card to open a door?

  • @jacobfoster9358
    @jacobfoster9358 4 года назад +3

    How about a tutorial on how to make an object grabable with both hands at once?

    • @adhochero6619
      @adhochero6619 4 года назад

      this is what i need. i have already tested it with the OVR stuff i have a working two hand rifle. but i just dont know how to use two hand holds with the XR toolkit.

    • @autumn_id
      @autumn_id 4 года назад

      @@adhochero6619 Hey, I just found exactly what you were looking for. There are three videos that can help you out with doing two handed weapons / objects. Check them out! Here's the link on the first video, I hope it will help
      ruclips.net/video/IX2EUAcocoM/видео.html

    • @mario123mario123
      @mario123mario123 3 года назад

      He made one :) Part 10 ;] ruclips.net/video/Ie0-oKN3Lq0/видео.html

  • @Duckamoly
    @Duckamoly 4 года назад +5

    Dani *uses your tutorial*
    his subscribers *SUBS TO VALEM OUR AMAZING VR LORD*

  • @wrath6692
    @wrath6692 4 года назад

    Nice thank you for the tutorial c:

  • @ndonkey
    @ndonkey 4 года назад +9

    Hey I'm having a bit of an issue. On your code when i walk by the draws the the draw and door get sucked up into the inventory slots. I have tried making a couple of changes but seem to make it all work or all break :D Is there anyway to set it so only certain layers can use the inventory or the object has to be held in the hand and dropped before being added to the drop zone?

    • @rikusoulz
      @rikusoulz 4 года назад

      Did you manage to solve it? I'm using the Interaction Layer mask to do it but you have to do it on every grabbable item

    • @ndonkey
      @ndonkey 4 года назад +1

      @@rikusoulz I some what just got around it. From memory I put the inventory areas into a new layer and allowed them to interact with standard grab items but not the doors, draws, levers, etc. It worked for what I wanted and it meant nothing else needed changing.

  • @JoseDaniel_Acosta
    @JoseDaniel_Acosta 3 года назад

    THANKS! :D

  • @borkly7926
    @borkly7926 4 года назад

    Can you teach climbing next? Great vid btw!

  • @eliassillen6107
    @eliassillen6107 4 года назад +2

    Next tutorial idea how to make a sword attack an enemy or something like that

    • @spidernh
      @spidernh 4 года назад +1

      That's just normal unity stuff, nothing specific to VR really. Except for that you're experiencing it in VR. Just take a collider and when it touches the enemy make the health go down.

  • @iuel42
    @iuel42 3 года назад +2

    Valem I have a problem - When I use the socket interactor with an object that has the offset interactable instead of the standard one, the attach transform doesn't work. Is there any workaround for this? Thank you in advance if you reply.

    • @productreviews2222
      @productreviews2222 3 года назад +1

      I am having the same issue, it grabs the object but won’t let me set the location

    • @kortalian
      @kortalian 2 года назад

      Same issue here. Did you ever figure out how to use an offset grab with the socket?

  • @polar1991
    @polar1991 4 года назад +1

    Do you have any experience with unreal engine? If you do can you make a series on it?

  • @piotrt.3652
    @piotrt.3652 4 года назад +1

    Hello, Valem thanks for this amazing series! I have one question maybe you know by any chance how to programmatically force interactor (hand) to put some interactable (let say ligthsaber) in hand and then also programmatically remove it from hand (direct interactor)?

  • @adhochero6619
    @adhochero6619 4 года назад +2

    Hi this tutorial is great and everything working when testing in unity though the link. but when i build and run it to my quest headset, the socket stuff is just gone it no visible socket zone on hover no predetermined object in the slot nothing. has anyone else had this problem. everything else works, even the climbing, just not the sockets.

    • @philipp282
      @philipp282 4 года назад

      I have the same problem. Did you find a way to fix this?

  • @bones99999
    @bones99999 4 года назад

    Great Tutorial. Can you snap multiple objects to the one point if they are different heights?

  • @Corysia
    @Corysia 4 года назад

    Yay!

  • @Frenoir
    @Frenoir 2 года назад

    do you have a video for OVR and oculus quest 2 not using XR interaction toolkit

  • @rcalastro0
    @rcalastro0 4 года назад

    Is there any easy way to resize the object inside the socket without having to extend the XR Socket Interactor? I tried to resize the "Attach Transform" scale, but it didnt work. Looks like the attach transform is used only to get the position and rotation. Thanks in advance! Valem your videos videos are awesome!

  • @kennl66
    @kennl66 4 года назад +1

    Is the XR Socket Interactor broken in Unity 2019.4.1f1? Mine is not grabbing anything i put in the sphere, it just falls through. I have a sphere collider set to trigger and added the XRSocket interactor but it's not working. (FIXED) read SilweriFPV comment here, has a fix for the XR Socket Interactable not working with URP. I just tested it and now works on the Quest.

  • @ellacouch8723
    @ellacouch8723 4 года назад

    Can you plz make a video about locks and keys and maybe number padlocks?

  • @TimT26
    @TimT26 4 года назад +2

    Please someone help me! I can drop object in mu dropzone, but I can't take them out of the dropzone. Can somebody help me?

    • @ValemVR
      @ValemVR  4 года назад +2

      hi Tim, do you have an error showing in the console ? :)

    • @TimT26
      @TimT26 4 года назад +1

      Valem Hi! No, I don’t have an error. It’s like when the object (Unity cube) is in the drop zone (sphere), it seems like they just don’t collide. I’ve done just as you did in your video. I’ve checked the collission matrix, but there is everything is normal there

    • @doriondouglas6176
      @doriondouglas6176 4 года назад

      @@TimT26 have you checked is trigger on the sphere collider? As in the drop zone collider?

    • @andra9812
      @andra9812 3 года назад

      @@TimT26 have you fixed it ? I have the same problem

  • @rikusoulz
    @rikusoulz 4 года назад

    Very nice job!
    Just one question, just noticed that if I have the two inventorys (left and right) when I continuous turn, I see like with less fps and is not fluent, not SMOOTH and If I disable the two inventorys changes and has a smooth turning move. Any way to solve this? I really want to have inventory and a normal turn, not stuttered and the only hint I have investigating is that is caused by the "Follow To The Side" script, that causes the turn to be less smooth

  • @themirlabs
    @themirlabs 4 года назад

    Would it not make it easier to child the obj to the head with the offset?

  • @grandobsidian
    @grandobsidian 3 года назад

    ive spent about two hours trying to replicate this and I cant actually get anything to snap into the socket or even seem to register a collision

  • @sn00ltheog45
    @sn00ltheog45 4 года назад

    Hey I was just wondering if there was a better way to track grabbed objects as I like the physics collisions of the velocity tracked movement type but I don't like the jittering when moving whit continuous. Is there a better way of doing it?

  • @nikolatotuhov
    @nikolatotuhov 4 года назад

    Hey is it possible to make the dropzone look like the object which needs to be grabbed?

  • @n.vano.7529
    @n.vano.7529 4 года назад

    Merci pour tes vidéos que je découvre en ce moment, dommage qu'elles ne soit pas en français 😉 signé : un camarade de Bxl ✌🔥!!!

  • @amadra826
    @amadra826 4 года назад

    Imagine making an inventory out of this

  • @francescomaddaloni9217
    @francescomaddaloni9217 4 года назад

    any idea how to do it with the standard oculus integration?

  • @niklashilger9172
    @niklashilger9172 4 года назад

    What i have to do to add in the "FollowToTheSide" Script, that i can adjust the rotation of the Drop Zone?

  • @mrslake7096
    @mrslake7096 4 года назад

    Thx

  • @nepal4190
    @nepal4190 4 года назад

    hey, do you know how to make a working spin the wheel in vr?

  • @gabrielcharlessanchez6729
    @gabrielcharlessanchez6729 10 месяцев назад

    Can I apply this in 3d not vr?

  • @devariiii
    @devariiii 4 года назад

    Is anyone else getting an InvalidOperationException: Collection was modified; enumeration operation may not execute error whenever they put something inside of an XR Socket Interactor?

  • @chowwill9828
    @chowwill9828 3 года назад

    Why is my snapzone can sometimes put the things in, sometimes not??

  • @athir3324
    @athir3324 3 года назад

    Hi . I follow all steps but still the snap not working for me

  • @nace6849
    @nace6849 4 года назад

    Hey valem, maybe you know the RUclipsr Dani (he has 1 mill subs) and he used your tutorial lol

  • @Ss-kk4ep
    @Ss-kk4ep 4 года назад

    My object enters the ball but when I want to take it out it stays there it does not connect to me at all does anyone know what the reason is?

    • @andra9812
      @andra9812 3 года назад

      I was searching for this comment cuz i have the same problem. Any solutions ?

  • @emiltoczyski260
    @emiltoczyski260 4 года назад

    The socket interactor doesn't work when you build the game ):

  • @mohammadrazakhan3852
    @mohammadrazakhan3852 3 года назад

    How to make sound when the controller hits any object ? Can any one help me please ?

  • @heldoct6154
    @heldoct6154 4 года назад

    Can u make VR android with controller? Not use oculus but other controller??

  • @smarter4645
    @smarter4645 4 года назад +2

    Regarding the script for the movement of inventory slots with the character. If u want it to follow in the same manner as "CapsuleFollowHeadset" from previous tutorial, replace the FixedUpdate with this:
    void FixedUpdate()
    {
    transform.position = characterTransform.TransformPoint(character.center);
    transform.eulerAngles = new Vector3(0, VRCamera.eulerAngles.y, 0);
    }
    i did not include the offset because I just need this for inventory slots around the belt of the player, for me orienting the gameobject is enough since I track the height.
    I placed three sphere objects with the socket component under an empty game object that has the script with the code above. Hope it helps.
    Btw, if anyone knows how to make the whole character not go through walls please let me know, the code from the tutorial series did not work for me.

  • @hamzamellahi3649
    @hamzamellahi3649 4 года назад

    where can i find these assets?

  • @vikramsindhu5901
    @vikramsindhu5901 2 года назад

    I am just gonna say this You should do udemy course with the latest content and a project within it that'd be great

  • @meeperhere
    @meeperhere 3 года назад

    the objects fly away

  • @aminer3v695
    @aminer3v695 4 года назад

    Are you french ?

  • @Doggie544
    @Doggie544 Год назад

    If this works and don’t waste 20 minutes of my time you a big saver❤

    • @ValemVR
      @ValemVR  Год назад

      so whathappened ? :D

    • @Doggie544
      @Doggie544 Год назад

      @@ValemVR idk lol

  • @pizzaguy6099
    @pizzaguy6099 4 года назад

    Am I able to sell a game with your source code

  • @big_ell123
    @big_ell123 3 года назад +1

    None of these tutorials don’t work for me

  • @lukenowlandfilms
    @lukenowlandfilms 4 года назад +4

    Is Unity paying you? Unity should pay you.