How to use Controller Velocity in Unity XR

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025

ความคิดเห็น • 62

  • @rangerguan9931
    @rangerguan9931 2 ปีที่แล้ว +4

    Just a remind. If you've done all as Andrew said but find the color of the cube never change. You probabaly need to go to "XRI Default Input Actions" And change the "binding". To me, Quest 2 , "deviceVelocity [RightHand XR Controller]" worked just fine for my right controller. Thanks Andrew again!

    • @PS-vj6jz
      @PS-vj6jz 10 หลายเดือนก่อน

      Or "_velocity.action.Enable()" - in my case.

  • @DefinedEdits
    @DefinedEdits 2 ปีที่แล้ว

    Thanks Andrew. I was struggling for a couple weeks trying to get the angular velocity of my controller working. It was always returning False, 0,0,0. Thanks for pointing out you need to map it to the specific controller type, and not generic XR controller.

    • @VRwithAndrew
      @VRwithAndrew  2 ปีที่แล้ว

      Happy to help! It's stuff like that that I also have to go through trial and error to figure out.

  • @cedricknapp2889
    @cedricknapp2889 3 ปีที่แล้ว +1

    I wasn't sure how to do this natively with the XR toolkit so I was manually calculating it by polling position change values 😅 thanks, this is a big improvement

  • @adityapatil9499
    @adityapatil9499 ปีที่แล้ว

    Thanks man what a wonderful video.

  • @HaniSharif
    @HaniSharif 3 ปีที่แล้ว

    Such a great teacher you are!! KUDOS

  • @makulVR
    @makulVR 3 ปีที่แล้ว

    As always I feel a litte bit smarter than I was before!
    A paint tutorial would be awesome! Like grabbing a virtual pen and paint on a wall.

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      I honestly put one of those together a few months ago. It needs a bit more work, and I haven't had a long enough span of time to finish the project, and put together a video. But, I hope to do a Spray Painter of sorts this year.

  • @matteuus337
    @matteuus337 3 ปีที่แล้ว

    Great video!!
    Would love to see how to do VR climbing with the new input actions sometime :P :D

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว +1

      Thanks! It's something that I'll be tackling in a few videos.

  • @r1pfake521
    @r1pfake521 3 ปีที่แล้ว

    Awesome video, as always.
    I would like to see tutorial about a more advanced XR RIg setup with multiple "controllers" per hand, for example one for normal interactions and one for teleport, that only shows when a teleport button is pressed and that allows you to move while grabbing an object. The XR example project on Unity Github, has something similar, but the implementation is a bit messy and it doesn't allow you to move while holding an object.
    I have a solution (that seems to work so far) so we could talk about it on discord if you want, but Im sure you have a better idea :D

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      Yeah, it's a bit overly complex for something that should be standard. I've done a couple of different things with disabling different controllers, and also making custom ones for when I need to teleport and hold an object as you describe. There is a very basic implementation in this course that I helped with.
      learn.unity.com/course/create-with-vr

  • @bovineox1111
    @bovineox1111 3 ปีที่แล้ว

    The interesting thing to me is to see how the interactables and I assume other XRToolkit classes an be subclassed to override the functionality. Have created a basic grab setup in Unity, but everyone (including me!) wants the HLA level of interaction, so I suspect I might be able to subclass the controller itself, or I might be able to render the hands independently, so the actual VR controllers become more like a marionette setup, and then render a model based on the controller's velocity. Lots to muse on... thanks for the video.

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      Keep an eye out for the XR Toolkit Roadmap. There's new stuff coming out that may help you.

  • @ManuelTorres-dg7ns
    @ManuelTorres-dg7ns ปีที่แล้ว

    Awesome explanation Andrew, thanks! Im using HP Reverb Controllers and its not working, Im selecting XR Controller in the Input Actions, because it doesnt apear HP option. Do you know if I can get the velocity with this controllers?

    • @VRwithAndrew
      @VRwithAndrew  ปีที่แล้ว

      That's a good question! I'd first try the generic XR Controllers. But, since the Reverb is built on Windows Mixed Reality, you may be able to use the Microsoft Mixed Reality Motion Controller Profile based on it's description.

  • @computer__eyez
    @computer__eyez 3 ปีที่แล้ว

    Elegant code here Andrew, along with explanation carrying us along. On 15:09 regarding code line 36:
    if(isSelected)
    {
    if (updatePhase == XRInteracationUpdateOrder.UpdatePhase.Dynamic)
    UpdateColorUsingVelocity();
    }
    you mentioned “we could write our own functionalities for velocity” on this line.
    Here is my 2 confusions
    (1) writing velocity code that measures “exact” value of velocity speed. Example:: if player throws cube at 10mph, cube turns yellow. Is there a formula that can register 10 mph.. (velocity speeds)?
    (2) Would I write this functionality underneath the “UpdateColorUsingVelocity();

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว +1

      Yeah, you'd have to convert miles per hour to meters per second. Which, you can find a simple converter online. You would then put in your functionality as you described. Just make sure it's within the if-statement for the update phase.

    • @computer__eyez
      @computer__eyez 3 ปีที่แล้ว

      @@VRwithAndrew Thank you, that clears things up a lot. Appreciate you brotha, thanks!

  • @elsyndur4415
    @elsyndur4415 3 ปีที่แล้ว +2

    I can't find deviceVelocity for the XR controller. I am using the Oculus Quest 2.

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      Do you know if you're trying to use OpenXR or the Oculus provider? That may have an effect on what's displayed. It just also be under the Oculus Touch controller.

    • @elsyndur4415
      @elsyndur4415 3 ปีที่แล้ว +1

      @@VRwithAndrew Oh, sorry, I spoke too soon. I just had to wait until around the 6:50 mark of the video, where you show how Action Type needs to be set to Value, and Control type must be set to Vector3. I should have watched the whole video before asking. Sorry, haha.

    • @rangerguan9931
      @rangerguan9931 2 ปีที่แล้ว +1

      Asked what I want to ask! Thanks both of you :D

  • @janpatrickconde4933
    @janpatrickconde4933 3 ปีที่แล้ว +1

    Great tutorial, but Im having some problems in the Velocity script. It seems that the interactor was deprecated and interactorObject doesnt have a get component.
    What should I do?
    P.s. Im planning on using this on a climbing script to proppel myself depending on the controllers velocity.
    Many thanks

    • @markus6056
      @markus6056 2 ปีที่แล้ว

      controllerVelocity = args.interactorObject.transform.GetComponent();

  • @yasarbaba2413
    @yasarbaba2413 3 ปีที่แล้ว

    Great tutorial video! Will the video about Hover and Trigger(together) come?

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      I saw your reply, but still not sure that I understand.

  • @irfanyaqoob4717
    @irfanyaqoob4717 ปีที่แล้ว

    is there a way, if after grabbing the object higher speed results in the un-grab?

    • @VRwithAndrew
      @VRwithAndrew  ปีที่แล้ว

      Possibly, if you're looking to just increase the speed, Grab Interactable has a "Throw Velocity Scale" in the inspector.
      If you need some more customization, you may be able to adjust that value using the controller's velocity when there's a Deselect.

  • @BrandonNyman
    @BrandonNyman 2 ปีที่แล้ว

    What is the best way to get the controller velocity and feed that into the continuous move XR interaction toolkit component so that the player automatically moves forward when the velocity is higher than a certain sensitivity?
    I have been able to use it to change the player movement speed but I can't get it to actually move without pushing the thumb stick like normal.

    • @VRwithAndrew
      @VRwithAndrew  2 ปีที่แล้ว

      I don't know the most straightforward way. I'd consider extending the Continuous Move Provider or creating a custom move provider.

    • @BrandonNyman
      @BrandonNyman 2 ปีที่แล้ว

      @@VRwithAndrew Ok thank you anyway. That is exactly what I figured but I am not sure how to go about doing it. But I will get there hopefully.

  • @JamesClarkRoguePimptastic
    @JamesClarkRoguePimptastic 2 ปีที่แล้ว

    I'm not sure if I'm thinking about this correctly, but is there a way to get a number from the velocity that can be used as a float? I'm trying to use velocity of the controller to change the speed of an animator.

    • @VRwithAndrew
      @VRwithAndrew  2 ปีที่แล้ว +1

      Yep! You can simply get the length of the vector by using .magnitude on the value. If you then need something a bit more fine-tuned you can lerp that value between 0, and a max magnitude variable to get a value between 0-1 for blending.

  • @_Garm_
    @_Garm_ 3 ปีที่แล้ว

    keep em coming :D where do you learn about the xr tool kit, i feel like when watching you its like magic but i learn a lot from it :D

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว +1

      Experimenting, trial-and-error, a lot of it is driven to by just making stuff for myself, work, and videos then figuring out how to do it.

    • @_Garm_
      @_Garm_ 3 ปีที่แล้ว

      @@VRwithAndrew thank you for sharing your experiments and fun stuff with us :D

  • @tctopcat1981
    @tctopcat1981 2 ปีที่แล้ว

    This video is so frustrating because you are helping people who may not know where you pulling things from. You lost me when you said I have already set up the velocity in the default XR. HOW did you do that part?????

    • @VRwithAndrew
      @VRwithAndrew  2 ปีที่แล้ว

      Yeah, I honestly don't know why I did that. You'll want to first look into creating Custom Actions, which I have a video on as well.

  • @ChaosContrl
    @ChaosContrl 2 ปีที่แล้ว +3

    Note that as of writing this comment, interactor is deprecated. The new valid way is:
    controllerVelocity = args.interactorObject.transform.GetComponent();

  • @citan554
    @citan554 3 ปีที่แล้ว

    Thanks for this great tutorial Andrew. Is there a way to similarly get XR HMD velocity? (using OpenXR, XR Interaction Toolkit) The Unity documentation seems to imply you can, but I cannot find it anywhere in the input bindings. Cheers

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      I'm not sure! You can look under XR HMD > Optional Controls > Device Velocity and see if that works for you.

  • @baroquedub
    @baroquedub 3 ปีที่แล้ว

    Sorry... stupid question... what would be a usecase for using the velocity to do something more useful than just changing the colour of the interactable? I'm assuming it's for better physics when throwing the object? Could you do a follow up to show that? Thanks!

    • @r1pfake521
      @r1pfake521 3 ปีที่แล้ว +3

      I use the controller velocity for melee attacks and only deal damage if the controller has a minimal velocity (based per weapon).

    • @KaosFireMaker
      @KaosFireMaker 3 ปีที่แล้ว +1

      As the other person said, melee weapons, but also for the reverse. Make damage go down if the velocity is high but erratic, to mitigate waggle spam.

    • @baroquedub
      @baroquedub 3 ปีที่แล้ว

      @@r1pfake521 Makes sense! thanks

    • @baroquedub
      @baroquedub 3 ปีที่แล้ว

      @@KaosFireMaker really nice idea. cheers

    • @GohanSama
      @GohanSama 3 ปีที่แล้ว

      @@r1pfake521 Seems like you could run into an issue where weapon moves fast, but does not deal damage. For example when doing all the movement with the wrist rather than swinging the controller.

  • @DoubledEthan
    @DoubledEthan 3 ปีที่แล้ว

    Hi Thank you so much, if you can a tutorial on how to disable the double pick up when you pick up with the rays?
    Example if i aim with my ray at two objects it will grab them both to my hand

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว

      I'd have to double-check that, depending upon your settings, it should just grab the first thing it hits.

  • @WesleyOverdijk
    @WesleyOverdijk 3 ปีที่แล้ว

    Holy shit you have a face! This is the first time I see your face! And it, is, gorgeous.
    Alright instructor man, back to learning.

    • @VRwithAndrew
      @VRwithAndrew  3 ปีที่แล้ว +1

      Ahaha, much appreciated! There's much learning to be done. :)