Introduction to VR in Unity - PART 10 : TWO HAND GRAB

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

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

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

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

  • @enchantedf0rest934
    @enchantedf0rest934 4 года назад +20

    You are the best vr unity teacher ever.

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

    You asked us to write how did we find this course, so...
    I just typed "Unity VR" in RUclips search and here I am. Your videos are literally the first ones in the search so its very easy to find them.
    I can't even describe how helpful your videos are. Thank you, Valem. Thank you very much.

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

      Thanks I really appreciate it ❤️

  • @nullname68
    @nullname68 2 года назад +19

    Hello again XR Interaction Toolkit 2.0 has made some of the things deprecated like the selectingInteractor so I updated the code so you can still use this in 2.0:
    public List secondHandGrabpoints = new List();
    private IXRSelectInteractor secondInteractor;
    private Quaternion attachIntialRoation;
    public enum TwoHandRotationType { None, First, Second }
    public TwoHandRotationType twoHandRotationType;
    public bool SnapToSecondHand = true;
    private Quaternion intialRotationOffset;
    void Start()
    {
    foreach (var item in secondHandGrabpoints)
    {
    item.selectEntered.AddListener(OnSecondHandGrab);
    item.selectExited.AddListener(OnSecondHandRelease);
    }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
    if (secondInteractor != null && firstInteractorSelecting != null)
    {
    if (SnapToSecondHand)
    {
    firstInteractorSelecting.transform.rotation = GetTwoHandRotation();
    }

    else
    {
    firstInteractorSelecting.transform.rotation = GetTwoHandRotation() * intialRotationOffset;
    }
    }
    base.ProcessInteractable(updatePhase);
    }
    private Quaternion GetTwoHandRotation()
    {
    Transform attachTransform1 = firstInteractorSelecting.transform;
    Transform attachTransform2 = secondInteractor.transform;
    switch (twoHandRotationType)
    {
    case TwoHandRotationType.None:
    return Quaternion.LookRotation(attachTransform2.position - attachTransform1.position);
    case TwoHandRotationType.First:
    return Quaternion.LookRotation(attachTransform2.position - attachTransform1.position, firstInteractorSelecting.transform.up);
    case TwoHandRotationType.Second:
    return Quaternion.LookRotation(attachTransform2.position - attachTransform1.position, secondInteractor.transform.up);
    default:
    return Quaternion.LookRotation(attachTransform2.position - attachTransform1.position, secondInteractor.transform.up);
    }
    }
    public void OnSecondHandGrab(SelectEnterEventArgs args)
    {
    secondInteractor = args.interactorObject;
    intialRotationOffset = Quaternion.Inverse(GetTwoHandRotation()) * secondInteractor.transform.rotation;
    }
    public void OnSecondHandRelease(SelectExitEventArgs args)
    {
    secondInteractor = null;
    }
    protected override void OnSelectEntered(SelectEnterEventArgs args)
    {
    attachIntialRoation = args.interactorObject.transform.localRotation;
    base.OnSelectEntered(args);
    }
    protected override void OnSelectExited(SelectExitEventArgs args)
    {
    secondInteractor = null;
    args.interactorObject.transform.localRotation = attachIntialRoation;
    base.OnSelectExited(args);
    }
    public override bool IsSelectableBy(IXRSelectInteractor interactor)
    {
    bool isalreadygrabbed = firstInteractorSelecting != null && !interactor.Equals(firstInteractorSelecting);
    return base.IsSelectableBy(interactor) && !isalreadygrabbed;
    }

    • @sweetflush277
      @sweetflush277 2 года назад +2

      THANKYOOUUUUOUUU REALLY THANKYOU!!

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

      @@sweetflush277 you are welcome :)

    • @TableLamp720
      @TableLamp720 2 года назад +2

      Holy Fuck, thank you so much for this, I actually love you. Unity said that my override arguments were invalid and I was lost for like 45 minutes rewatching the video. You're literally Him.

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

      thanks man you saved me 10 hours of searching the new scriptline

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

      I use the snap turn provider and when i turn my interactable gets offset every time i have tied everything i could think off but nothing worked for me

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

    Thank you for this series! You answered every question / problem I had run into trying to setup with Oculus Integration. You are amazing.

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

    He's done it again, another life saving tutorial. Absolutely beautiful, keep up the good work man

  • @TheMrPawolo
    @TheMrPawolo 4 года назад +40

    For this tutorial You are the best Valem :DDDDDD And while I playing your script i found bug if on TwoHandRotationType you select "First" and then you grab rifle with two hand and start doing circles in air with your first hand then gun will rotate in unexpected way. Fortunately it can be easly fixed by changing this line of code
    "targetRotation = Quaternion.LookRotation(secondInteractor.attachTransform.position - selectingInteractor.attachTransform.position, selectingInteractor.attachTransform.up);"
    to this
    "targetRotation = Quaternion.LookRotation(secondInteractor.attachTransform.position - selectingInteractor.attachTransform.position, selectingInteractor.transform.up);" Can't wait for your next tutorials :D

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

      Oh you're right thanks for pointing that out! :o

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

      @@ValemVR Hey, How do I create a continuous motion turn provider instead of snap turn provider?

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

      Thank you

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

      @@michaelramczyk4721 there is already a script called something like: continuous turn provider (device-based)

    • @Noodles-jz5jb
      @Noodles-jz5jb 2 года назад

      @@michaelramczyk4721 add the continuous turn provider conponent instead of the snap turn

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

    Thanks for this amazing tutorial. I have no words to describe how much easier it made my journey to VR GameDev. The last part of video made me to consider learning more complex math :0

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

    Very good tutorial. I followed every video and I think almost every new topic about VR in Unity is covered. Thanks a lot, you really helped me :D

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

    Amazing tutorial, Valem. So happy to have caught up in your tutorial series. So cool!

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

    @Valem as always you ROCK! Thanks for answering the question with this video.

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

    Wow, I've learnt a lot from this tutorial. You're quick, concise and to the point. Much better than many VR tutorials on the Udemy platforms. I found this one via googling "two hands grab unity VR" or something like this and bang! An elegant solution with many interesting configuration options. Thanks for this!

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

    Finished all of it! cant ait to use this knowledge, thankyou so much Valem you've motivated me and im sure many others to explore the world of VR Dev!

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

    best Vr Unity RUclipsr ever!

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

    Great Tutorial as usual, with a sense of going as far as possible on the topic ( for example when you create the TwoHandRotationType for later making it easier to change on the fly ). For the next one, I would love
    A) Flying as a locomotion method ( a topic you covered in other videos) - it would also allow to work on gravity applied to the VR rig
    B) Drawing in air, and then moving the drawn object around
    Again congratulations and Keep up this amazing serie !!!

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

    Super Tutorial on how to do a 2 handed grab. Very well explained.

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

    I could listen to you talk all day XD

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

      legit my new go to for Unity dev.

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

    @Valem, I found this course while searching for VR tutorials. I started a new job at a company and they want a VR-application :) So now im learning the basics and i will have to make that app :P but with your tutorials and help on discord i will be able to do it :D

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

    Great tutorial, amazing walkthrough for any VR headset

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

    Thanks for the tutorials. They have helped me a lot and are really easy to follow along. I think a tutorial about gun recoil would be very cool seeing as you have two guns right now.

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

    I absolutely LOVE your videos valem
    it would be really cool if you showed us how to make the character jump

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

    Great videos so far, a tutorial on riding a motorcycle and steering it with one or both hands on grips would be awesome. Throttle with trigger would be fine if rotating throttle is too difficult.

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

    Awesome course!! I have zero experience and am loving the content and ease of learning!
    In the next video I would love to learn how to do custom hand poses so when grabbing certain objects they have a particular pose.

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

      Thumbs up for this suggestion. I was expecting it already in this tutorial since the intro picture seems to show a custom pose for the left hand.

  • @blazeplayz3158
    @blazeplayz3158 4 года назад +11

    I just made a fan game of half life in vr called Half Life Alyx and sold it to this company called valb for $20 so thx for making this video!

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

      bruh moment

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

      Yeet and lmao

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

      Lmao imagine if half life alyx was made in unity

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

    Yes. YES! You bloody amazing VR master. Now, give me MOAR! 😘

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

    Nice tutorial. Smart and dense. Thanks.

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

    Great stuff man best vr tutorials

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

    Your VR tutorials are awsome! Would love to see a VR racing game tutorial.

  • @privateHandle731
    @privateHandle731 2 года назад +2

    This is AWESOME for guns that point in the direction of the first Attach Transform, but what code might we use for e.g. wielding a Long Sword with 2 hands? Any ideas?

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

    love the vids mate! And they are so much help

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

    Hey Valem! Your probably not going to see this but there is one thing you must have a tutorial on for VR, and that's jumping! I'm trying to make a parkour game but you have no videos on how to add jumping and I kind of need this. Anyways this is a suggestion for a video because I am stuck with my game until I can add jumping. Thanks Valem for the awesome tutorials!

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

    Keep up the good work my friend!!

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

    Super helpful series, thanks a lot!

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

    Thank you so much for doing these!

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

    Thanks for the tutorial! Love it.
    I am currently working on a recovery VR game for apoplexy in hospitals, this tutorial really helps me a lot.
    Just wondering if it possible to have a tutorial of extension of hand position?
    for example, having your hand in the position 2x further than it is actually in?

  • @otterlyfoxed
    @otterlyfoxed 4 года назад +17

    What about my 3rd hand?

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

    great tutorial. i like your approach to this two hand grab. one thing though, how would you keep the gun attached to the second hand if you let go of only the first hand? like if using a bolt action rifle and you want to reload?

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

      One year late but you could remove the piece where it sets the second interaction to null in OnSelectExited

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

    Can you make a tutorial about all the things we need to know for VR development in the new 2020 version of Unity?

  • @Sendit77
    @Sendit77 7 месяцев назад

    you have renewed my faith in french people

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

    Love the series. Very isnpiring. Maybe it's already time to get more into the visual aspect of VR-Development. Like how to create a simple body in Blender, make a skeleton and link it in unity to your hands and headset. Just an idea. Enjoy your day!

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

    In latest version of XRTK is obsoleted that boolean types of interactor but they are replaced with interface IXRSelectInteractor So if you want to try this tutorial you may have to check out the patch note or try it in particular version of unity using in this video.

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

    amazing series

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

    Thanks for such a thorough tutorial on that! That was so much code that it seems maybe recommendable to simply make it from scratch, rather than using the XR interaction toolkit. With that toolkit being in such a “preview”/beta mode it seems a little naive to base too much on beta code.

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

    Thanks man! This video is very helpful

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

    This would be a very big topic and would probably need a new series but could you do a tutorial on multiplayer with mirror networking?

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

    amazing tutorial.Thanks!

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

    Thanks. Good series.

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

    Hi Valem, Can you make a Bow & Arrow tutorial please?

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

    It would be really cool if you managed to make a grappling hook in vr

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

    Please do a tutorial covering haptics, like when you pull trigger on gun make it vibrate the correct controller. I figured out how to use XRController.SendHapticImpulse() but I'm having a hell of a time trying to figure out how to pass in the correct controller that is holding the grip with trigger, as of now I just assign which controller in the inspector but I want it to automatically assign the correct controller. No idea why something so basic has no documentation on Unity.

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

      I figured it out if anyone is interested, I used the InputHelpers.Button and InputHelpers.IsPressed to check if the trigger of left or right hand xrcontroller is pressed each time I pull the trigger while holding gun. Similar how he uses these helpers in the teleportation video.

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

    Thank you teacherji, from India with 💗!:)

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

    For me the
    'protected override void OnSelectEnter(XRBaseInteractor)'
    and the
    'protected override void OnSelectExit(XRBaseInteractor)'
    are errors. It both says it has no suitable methods found to override

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

      You dont use that anymore. Use 'protected override void OnSelectEntered(SelectExitEventArgs args)'

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

      I have the same issue

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

    I wish youd do more SteamVR rig videos the XRrig doesnt work with my Mixed Reality Headset

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

    This series is so useful!

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

    I would love a comparison video between the current VR systems such as SteamVR, Unity XR Toolkit, VRTK and MRTK. Most examples online are dated a year or older, and with the ever-changing SDK I would love to hear a professional's opinion on the matter

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

    Love you mannn

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

    Great video Valem, thank you for sharing! I noticed this but the functions OnSelectEnter and OnSelectExit have been renamed to OnSelectEntered and OnSelectExited respectively in XR Interaction toolkit 0.10, I'm putting this out there for anyone watching. Thanks a lot!

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

      Me too, I'm getting this too. I think this is because of the new unity input system. Please let me know if you find a solution to this

    • @tobyyarnley-cave1914
      @tobyyarnley-cave1914 3 года назад

      @@VonchkynProduction they havent been renamed, those functions are deprecated but they should stillwork!

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

    Salut Valem, super tutoriel (je progresse en anglais grace a toi😁).
    Je voulais juste savoir comment adapter ce tutoriel à un volant de voiture.
    Dans la vidéo, c'est l'arme qui s'approche de la main mais pour un volant de voiture, ça doit être la main qui s'accroche au volant.
    Voilà, si vous avez des pistes, je suis preneur...😊😊😊

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

    Hi, i'm getting an error regarding onSelectEnter. It says that it is deprecated. Is there another way to do this?

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

      same.

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

      Same

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

      [System.Obsolete]
      protected override void OnSelectEntered(XRBaseInteractor interactor)
      {
      // Debug.Log("First Grab Enter");
      base.OnSelectEntered(interactor);
      attachInitialRotation = interactor.attachTransform.localRotation;
      }
      [System.Obsolete]
      protected override void OnSelectExited(XRBaseInteractor interactor)
      {
      // Debug.Log("First Grab Exit");
      base.OnSelectExited(interactor);
      secondInteractor = null;
      interactor.attachTransform.localRotation = attachInitialRotation;
      }
      It's work for me

  • @DavidGonzalez-oj1ic
    @DavidGonzalez-oj1ic 4 года назад

    Man, if you had Patreon I would support you.

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

    A lifesaver

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

    Has anyone else run into the problem of having multiple copies of the same gun prefab, but only having it work on some of them? I have it working right on a couple of guns, but for some guns it only works on some of the copies. For example, I can add 4 identical machine pistols and have it work on 2 or 3 of the 4, but never all of them.

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

    Please make a tutorial for selective inventory slots. When ever i walk too close to the cupboard door it snaps to the inventory snap point.

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

      PS these two hand grab point guns hate your inventory snap points

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

    great vid!

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

    Amazing content, I am binge-watching all of your videos right now as I am creating a VR app for my diploma. I know this video isn't recent, but I'm really hoping for a reply :) Would you be willing to create a tutorial on developing a TiltBrush-like app for VR using these XR tools? Very basic - just one brush that you can draw with, maybe with a few colors to choose from + an eraser. Thank you so much for everything! Btw love your attitude in all of your videos, it makes them very pleasant to watch :)

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

    Hi Valem, I think with the grab interactable; movement type kinematic is shaking around hands when moving, but with instantaneous movement type which solves the shaking issue, it cannot be grabbed correctly and many weird angles. Do you think we can fix the shaking issue.

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

    for some reason whenever I have the secondary grip near an XR socket interactor, it snaps there. any reason why?

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

    It's cool ! I've already subscribed to your Patreon. Can you add a short tutorial on how to grab a gun with fingers wrapped around it, like Pavlov VR, Onward...;use oculus XR toolkit.

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

    im only having a issue because im not able to pick up the rifle I don't know why but its a little frustrating

  • @diiba_
    @diiba_ 4 года назад +7

    Does unity XR support openVR yet? I have a valve index but I want to start learning the XR toolkit rather than steamVR plugin as it would support more platforms

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

      steam vr sdk, its what im using and it works wonders! and there is one for open xr but its garbage and buggy. and steam vr does support alot of platforms wdym.

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

      @@wtfimcrying I just went by what Valem said in the first episode when explaining the upsides of unity's XR toolkit, I'm just worried about compatability issues when developing with the index controllers and individual finger tracking since I don't have any other controllers headsets to test on

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

      @@diiba_ the xr interaction toolkit doesnt support input from steam headsets.

  • @ES-VIRAL
    @ES-VIRAL 4 года назад

    Hello, GREAT CHANEL. My great problem is : how to build for others PC USERS ? How can I create the file ? Thanks

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

    This series has been great is it possible if you were to make a video Tutorial on VR with enemy AI

  • @kingsway.183
    @kingsway.183 4 года назад +1

    Hey man I’ve watched your videos for a long time, could you please make a tutorial on vr enemies and allies. Or maybe a tutorial for moving cars or something that you can hop on and they move.

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

    Hey Valem, I love your videos and I would love to know how to make a good arm-swinging movement. I ask this because I’m getting a really difficult time trying to make one haha.
    Keep doing great videos!

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

    hi valem I have watched all your videos in this clip , it gives me great efforts in my VR dev,hope you continue working and upload more videos about this series for beginner,nice work! And i'm working on PC I wonder what laptop can still work well on this for dev project🤔?

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

    Can you do a VR keyboard tutorial?

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

    Hi! Thanks for all your awesome content, would you be able to make a video on custom hand poses? Like when you grab the gun if your hand could hold the barrel and trigger properly? Thanks!

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

    VALEM, THE NEXT THING SHOULD BE " HOW TO CREATE A CONTINUOUS TURN PROVIDER , instead of a snap turn provider.
    I created a game with the basic components that you're tutorials have taught us. I have two planets, faux gravity, and a teleportation portal on both planets. I have a launch pad that can launch you off of the planet onto another small planet that is orbiting the main planet, but the issues is that, in order to walk on a planet that is spinning around, you have to be a child of the planet. The other issue is that, If I hit build and play, my controller doesn't work any longer. I created a secondary character controller to allow me to walk on the planets, and to jump. It is a great game concept, and I could really use some help. I have stumbled my way through this far.
    MAYBE, you can use my game build that is an adaptation of what you haave taught us in your next lessons to get some real crazy gaming variants.
    I have Faux Gravity, the planets use attractors to let me walk on their surfaces.
    I have a new player controller that allows me to walk on the planets and have the proper orientation on a sphere. .
    I have created a Jump provider and a Jump Limiter that allows me to jump only once, without being grounded.
    I have a created a Faux Gravity switch that lets me teleport from planet to planet and switch the gravity attractor.
    I have created a pause function, and a pause menu.
    I have created a start menu.
    I have created 3 levels, teleporters to switch scenes, and locations inside of scenes.
    I NEED SOME HELP!!!!!!!!!!!

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

    I was bout to break out mad cause the override wasn't valid, and all I had to do was just type "ed" after enter and exit. I wasted too much time on this. Thanks for the tutorial regardless.

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

    on: item.onSelectEntered.AddListener(OnSecondHandGrab);
    "XRBaseInteractable is obsolete... Use selectEntered"
    and if I write: item.selectEntered.AddListener(OnSecondHandGrab)
    Argument type 'void' is not assignable to parameter type 'UnityEngine.Events.UnityAction

  • @lunar-skiehackett747
    @lunar-skiehackett747 2 года назад +1

    "the gun is moving like it has parkinson"

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

    How to eat things in vr would be epic

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

    With the TwoHandGrab script I cant take back an object from a snapzone. Its like the object is stuck in it. I can grab the SecondHandGrab point, but the first Grab is stuck. Help :D And thank you for those amazing tutorials. Salutation de Belgique!

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

      I understood the problem but I know nothing about coding so I have some trouble to fix this.
      The function useful to grab your object is named "OnSelectEnter" and is present both in the standard XRGrabInteractable and in TwoHandGrabInteractable scripts.
      In the first one However, the "OnSelectEnter" contains a lign of code with a comment saying "this is usefull to override sockets", wich is lacking in the TwoHandGrabInteractable script. And THIS IS what we need to fix the problem! I tried to copy/paste it, but there is some missing elements. Here is the lign in question:
      "406: // special case where the interactor will override this objects movement type (used for Sockets and other absolute interactors)
      m_CurrentMovementType = (interactor.selectedInteractableMovementTypeOverride != null) ? interactor.selectedInteractableMovementTypeOverride.Value : m_MovementType; "
      m_CurrentMovementType and m_MovementType doest are lacking in TwoHandGrabInteractable because they are in another script called "XRBaseInteractable" which XRGrabInteractable is derived from. And the problem is that our script "TwoHandGrabInteractable" is not also derived from that one, but from XRGrabInteractable.
      I tried to change that, but I could not grab my gun anymore.
      Then Im trapped. Please Help :D

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

    If I try to initially grab an object's 2nd grab point, my scene crashes.
    It works if I grab the actual attach transform point and THEN grab the 2nd grab point, but not the other way around.
    Does anyone have an idea how to solve it?

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

    This tutorial seems to be obsolete, a lot of this stuff doesn’t work with the new unity xr toolkit. Anyone know of a newer one?

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

      hope this is still useful
      public List secondHandGrabpoints = new List();
      private XRBaseInteractor secondInteractor;
      private Quaternion attachIntialRoation;
      public enum TwoHandRotationType {None, First, Second}
      public TwoHandRotationType twoHandRotationType;
      public bool SnapToSecondHand = true;
      private Quaternion intialRotationOffset;


      void Start()
      {
      foreach (var item in secondHandGrabpoints)
      {
      item.selectEntered.AddListener(OnSecondHandGrab);
      item.selectExited.AddListener(OnSecondHandRelease);
      }
      }

      public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
      {
      if(secondInteractor && selectingInteractor)
      {
      if (SnapToSecondHand)
      selectingInteractor.attachTransform.rotation = GetTwoHandRotation();
      else
      secondInteractor.attachTransform.rotation = GetTwoHandRotation() * intialRotationOffset;
      }
      base.ProcessInteractable(updatePhase);
      }
      private Quaternion GetTwoHandRotation()
      {
      Quaternion targetRotation;
      if (twoHandRotationType == TwoHandRotationType.None)
      {
      targetRotation = Quaternion.LookRotation(secondInteractor.attachTransform.position - selectingInteractor.attachTransform.position);
      }
      else if(twoHandRotationType == TwoHandRotationType.First)
      {
      targetRotation = Quaternion.LookRotation(secondInteractor.attachTransform.position - selectingInteractor.attachTransform.position, selectingInteractor.transform.up);
      }
      else
      {
      targetRotation = Quaternion.LookRotation(secondInteractor.attachTransform.position - selectingInteractor.attachTransform.position, secondInteractor.transform.up);
      }
      return targetRotation;
      }


      public void OnSecondHandGrab(SelectEnterEventArgs args)
      {

      secondInteractor = args.interactor;
      intialRotationOffset = Quaternion.Inverse(GetTwoHandRotation()) * secondInteractor.attachTransform.rotation;
      }
      public void OnSecondHandRelease(SelectExitEventArgs args)
      {

      secondInteractor = null;
      }

      protected override void OnSelectEntered(SelectEnterEventArgs args)
      {

      attachIntialRoation = args.interactor.attachTransform.localRotation;
      base.OnSelectEntered(args);
      }
      protected override void OnSelectExited(SelectExitEventArgs args)
      {

      secondInteractor = null;
      args.interactor.attachTransform.localRotation = attachIntialRoation;
      base.OnSelectExited(args);
      }


      public override bool IsSelectableBy(XRBaseInteractor interactor)
      {
      bool isalreadygrabbed = selectingInteractor && !interactor.Equals(selectingInteractor);
      return base.IsSelectableBy(interactor) && !isalreadygrabbed;
      }

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

      @@nullname68 thank you so much that is amazing. I did not expect an answer at all nonetheless like that, that’s so helpful.

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

      @@immortalhamster1645 Im glad i was helpful

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

      @@nullname68 Hi ! Thank you for this update but it seems to not be working for me. I have the error: The type or namespace name 'SelectEnterEventArgs' could not be found. Any solution ?

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

    This was Amazing thank you Valem! Does anyone know how to map a Jump button? Would be a major help for what I am working on

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

    Hey Valem, great tutorials Thx a lot, what about a tutorial for bow and arrow or slingshot maybe ?

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

    Thanks!

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

    Thanks for the great tutorial, it all works except when i let go on the seccond hand grab the gun still position is effected by the second hand controller. Any fixes please.

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

    Hi Valem, really good tutorial! I have a question. How can I add "weight" to the gun? For example I grab the rifle only with the right hand and I want to feel the weight of it on the front. How can I do that?

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

    Any way to adapt this script for a ball?
    When I grab a ball with my other hand, it rotates the entire ball in the opposite direction.
    Maybe it has something to do with the position of the second hand grabpoint?

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

    Nice tutorial, but please, use camelCase for variable names to make it less confusing and more readable (even for you :D )

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

    How would one make a single collider that can be grabbed and interacted with both hands? Let's say like a wheel that you want to be able to be grabbed from any side with both hands

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

      you would have to choose one hand to be the dominate controlling hand, or calculate the average input from both hands and apply that to the wheel. since you hands can move in two different directions and the wheel can not. a big part of selling the effect though is to parent your hand models to the wheel while holding onto it.

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

    Idk if i am the only one having this but when i grab the second position it automatically detaches from the gun so it doesn't follow the hand
    I have to delete the OnSecondHandRelease method for it to work

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

    Boss, how to remove and reinsert the magazine ?

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

    I love your toutorials but i have a little problem. I want to make a movement in Space like "swimming" or using a jetpack but i dont know how to do that ;-; can you please help me?

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

    What is the best version for VR development right now?

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

    You are so awsome!
    Could you make a video about interacting with InputiFeld UI element?
    And also make a virtual keyboard please :D

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

    I'd like to see a tutorial on enemy's in a zombie state or like a shooter game

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

    can you advise how this would work on OpenVR / steam VR, or do a seperate video on PAtreon as im planning to join in September. im having too many issues with XR to use it