Custom Input Actions for Unity XR

Поділитися
Вставка
  • Опубліковано 19 сер 2024
  • Oh hey! Are you looking to learn more about VR Input using Unity's Input System? Well, you're in the right place.
    Supporting Videos:
    • How to Setup XR Toolki...
    • Setting up OpenXR in U...
    Documentation:
    docs.unity3d.c...
    docs.unity.cn/...
    Support my work, and get access to source code!
    / vrwithandrew

КОМЕНТАРІ • 151

  • @Xzarations
    @Xzarations 3 роки тому +25

    Dude.... Your beard is so majestic and amazing

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +2

      Ahaha, thanks homie, I grow it myself.

  • @JackAaronOestergaardChurchill
    @JackAaronOestergaardChurchill 3 роки тому +6

    This is really great to see, super helpful to be taken through the input actions. Also love the little popup video of yourself in the static moments, great idea! Keep them coming, Thank you!

  • @TeaZ
    @TeaZ 3 роки тому +2

    Every time I hit a snag, Andrew releases some amazing video and I'm able to learn so much. Thank you for doing this.

  • @colsanders7571
    @colsanders7571 2 роки тому

    you are the only person who has actually helped me understand how to use the new input system. thanks!

  • @andrewtoth7674
    @andrewtoth7674 Рік тому

    THANK YOU.
    THANK YOU THANK YOU THANK YOU!!!!
    I've never used Unity before, but I'm using it to Prototype an idea I have for my VR headset. This was exactly what I wanted to do (run scripts based on inputs) and I finally found your video that explained exactly what I wanted to do.
    *Well, not /exactly/ but 95% close enough! I'm using the sticks primarily, and float2 is a new datatype for me. (I come from an embedded real-time hardware background)
    The documentation is unclear because it often assumes background knowledge on several other bodies of documentation and I couldn't hold all that in my head. I'm struggling to understand the necessary link between dropdowns in the Unity Editor and getting code to run... and then actually writing the code to do what I want!
    This video (and the two you referenced at the beginning): Super helpful. Thank you so much!

    • @VRwithAndrew
      @VRwithAndrew  Рік тому

      Don't worry, the Input System documentation goes over my head at times as well.

  • @richardhughes9605
    @richardhughes9605 2 роки тому

    Thank you so much. I've been tearing my hair out for a while trying to do this and now it's working.

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому +1

      Happy to help! I don't want you losing all your hair and looking like me.

  • @JoseDaniel_Acosta
    @JoseDaniel_Acosta 3 роки тому

    I HATE U!!! THIS IS AMAZING!!! I wanted this months ago and u are the first person that teach me this 🎉🎉🎉🎉🎉

  • @lge8170
    @lge8170 Рік тому

    Really underrated video, super clear explaining! Great job!

  • @benemy9
    @benemy9 Рік тому

    This was really helpful for our university project, thanks a lot man

  • @bblakeyyy
    @bblakeyyy Рік тому

    This video is awesome. Super simple to get to grips with. Shoutout to you my friend :)

  • @ryanhu1012
    @ryanhu1012 2 роки тому

    what a nice tutorial video! really detail but easy to understand !
    and the tempo、voice really makes me feel ease to learn not getting annoyed.
    I got more to learn. hope to see more about this kind of video.
    thank you Andrew.

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      You're very welcome Ryan, thanks for the kind words. :)

  • @jihyeonlee4138
    @jihyeonlee4138 Рік тому

    THANK YOU Sooo much!! It helps me a lot👍Your explanation is detailed, so even beginners can easily follow it!

  • @user-un9ht6vd2i
    @user-un9ht6vd2i 5 місяців тому

    Your video really helps me a lot. All your tutorial video is awesome !!!
    Really thank you💖

  • @AbdulRehman-lq9nf
    @AbdulRehman-lq9nf Рік тому

    Thank you sooo much I was looking for this for many months

  • @doriondouglas6176
    @doriondouglas6176 2 роки тому

    thanks! I used this to give the player footstep sounds! very useful

  • @cjgstudio
    @cjgstudio 3 роки тому

    How topical. Just writing a research paper on accessibility in VR and was doing this earlier, look forward to this thanks for sharing

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      Glad it was helpful!

    • @cjgstudio
      @cjgstudio 3 роки тому

      @@VRwithAndrew All of your work is. Get through a video a day to see what ive missed. Keep it up dude youre great

  • @pfeifenderleidender7320
    @pfeifenderleidender7320 Рік тому

    What a king! 👑 Thanks Andrew.

  • @Unmighty1
    @Unmighty1 2 роки тому

    Thanks so much for this video!! Quite difficult to find videos on this right now.

  • @jake-vr
    @jake-vr Рік тому

    Incredibly helpful, thanks Andrew!

  • @spacewalkgames9173
    @spacewalkgames9173 Рік тому

    Thanks, Andrew, this is beneficial information.

  • @gonzalolo
    @gonzalolo 3 роки тому

    Thanks mate, finally I got it working, it is so much complicated than the previous system hehe

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      You'll get the hang of it! They do need to do a bit more effort in phasing out some of the inputs. Takes a bit too much trial-and-error at the moment.

  • @Ninquiet
    @Ninquiet 2 роки тому

    This is exactly what I was looking for, thank you so much

  • @nickchild5870
    @nickchild5870 2 роки тому

    you are a saint and a scholar

  • @lucashorta4272
    @lucashorta4272 4 місяці тому

    nice I really want to figure out how I can use a custom pose using xr hands to trigger a custom input action for things like this

  • @LordTT8
    @LordTT8 Рік тому

    Thanks for your help !

  • @victorfloerchinger7940
    @victorfloerchinger7940 2 роки тому

    I love you so much you are my saviour !

  • @TimFordMedia
    @TimFordMedia 3 роки тому

    Great tutorial as usual!

  • @safdardeveloper3804
    @safdardeveloper3804 Рік тому

    Very good tutorial video.

  • @Beerburp
    @Beerburp 3 роки тому

    Thanks Andrew!!

  • @PraveenMax
    @PraveenMax 2 роки тому

    Thanks for this useful tutorial!!!

  • @yasarbaba2413
    @yasarbaba2413 3 роки тому +1

    Great Tutorial!

  • @171694
    @171694 3 роки тому +1

    Thanks Andrew!!!

  • @kiniuuu
    @kiniuuu 3 роки тому

    Great help, thank you!

  • @TheEnemyBoss
    @TheEnemyBoss 2 роки тому

    Thank you so much for this.

  • @levexis
    @levexis 8 місяців тому

    great video, and beard 😊

  • @valentinprieto5906
    @valentinprieto5906 2 роки тому

    Thank you so much !

  • @onurpekdemir
    @onurpekdemir 3 роки тому

    Thanks for this, Andrew. Your videos are a big help and time saver! 👍 Maybe you could do a deep dive into the "Interactions" area of the XR Toolkit. I'm absolutely not sure if I'm using it correctly as I only can make one Interaction work at a time for a given Action (e.g. I can't combine "Tap Interaction" with "Multi Tap Interaction" or "Press" Interactions on one Button). The official Documentation is a bit confusing and I haven't found anything else to solve my Problems yet. 🤪Best Wishes for your Channel!

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      Thanks! I'll see if I can look into it. A lot of it is just trial and error, and going through some of the code in the package.

  • @Ran_Pang_Pang
    @Ran_Pang_Pang 2 роки тому

    thx Andrew!!

  • @esa0832
    @esa0832 2 роки тому

    Nice Tutorial

  • @partharora1090
    @partharora1090 2 роки тому

    Thank You so much!!!!!!

  • @GeorgiDimitrovX
    @GeorgiDimitrovX 2 роки тому

    Many thanks

  • @nanyubusnis9397
    @nanyubusnis9397 10 місяців тому

    Does a value *have* to change for it to run "performed" ? I mean, even though a pressed button has value 1 all the time, as long as it is 1, isn't it still being pressed, thus performed? I would have expected it to be called "changed" if they meant it that way.

  • @indikaWijesooriya
    @indikaWijesooriya 3 роки тому

    Golden Content!

  • @kitws
    @kitws 2 роки тому

    Thank you!!

  • @mostafakhamis5204
    @mostafakhamis5204 2 роки тому

    Thanks alot!

  • @r1pfake521
    @r1pfake521 3 роки тому

    I start to like this new input system. I have a setup where I mock the VR controller, so that I don't have to put on the headset for every simple change. With this input system I can just map the already exising Right/Left controller actions (for example Activate) to additional keyboard inputs without writing any additional "VR Mock" code.
    Now I only have to figure out how to map the stick axis to 4 buttons (Up, Right, Down, Left), I could do it in code and just check the axis position, but I assume there is a way to already do this in the input system editor, to handle it as a proper button instead of axis vector.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      Yeah, you can use Sectors on a Vector2. I couldn't find a way of doing the same with a touchpad so I ended up making my own thing.

  • @ryanstripreport
    @ryanstripreport 2 роки тому

    Thanks

  • @nikunjsethi9351
    @nikunjsethi9351 2 роки тому

    the way you implemented the color changing functionality, its like you press the trigger to its maximum value its color changes and as soon as you release it, it changes back. I want to do something like this in which when I press the trigger value , the color should change according to that, but it shouldnt revert back when i release the trigger. Can anyone help me with that?

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      I'd probably have a variable in the script for holding onto the max amount the trigger is being pulled. So, when the trigger is pressed, I'd check to see if the trigger value were getting is greater than the max value. Then, update the material, and update the max amount variable.

  • @alex__rios
    @alex__rios 2 роки тому +1

    I followed all the steps for the primary button input action, but nothing is triggering (print statement inside Toggle isn't going off). Are there any additional settings that I should be looking out for?
    Things I've done so far: -set input handling to New and Both in player settings. -added all controller profiles in the XR Plugin Management settings. - added action.Enabled() and action.Disabled() in OnEnable() & OnDisable() respectively.

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      Double-check the OpenXR settings that you have the right Controller Profiles added.

    • @alex__rios
      @alex__rios 2 роки тому

      @@VRwithAndrew Yes, they’re all there.

    • @Dov-ke6cl
      @Dov-ke6cl Рік тому

      I doubt this is still relevant to you, but I just had the same issue. The fix was to change the button binding path (03:37) from "primaryButton" to "menu". I also added both left and right xr controller bindings to the same action.

  • @esa0832
    @esa0832 2 роки тому

    I'm confused about the joystick controller.. how do I detect it?

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      You'd need to set up an action of type Value > Vector2. You can see an example of this within the Default Actions if you look for the "Turn" action.

  • @jonnathanwilson5300
    @jonnathanwilson5300 2 роки тому

    Thank you for this video.
    I am a beginner. I just can‘t toggle a particle system on an off in VR. Could you or Somebody else help me please.
    I am about to get insane.

  • @Antifr33z3
    @Antifr33z3 2 роки тому

    Hey, it seems like it doesn't fully work for me. I wrote toggle script, mapped it to left controller primary button, and in play mode, whenever I press it, my gameobject disappears, but it won't go back to active state again. It stays disabled, how do I fix it? I did everything like you in the video :/

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      You may just need to double-check the Toggle Code so that the bool is flipping properly. Check to see if you have the exclamation point is being using on the isActive line.

  • @juliorobot5864
    @juliorobot5864 2 роки тому

    Hey can i have the link for this project ?? thanks great WORK ^_^

  • @tlskillman
    @tlskillman 2 роки тому

    Great video, clear and well paced. One thing I'm unclear on is if you have multiple Action Maps defined and they have overlapping Actions, what happens? Does the first one fire but not the rest, or do they all fire. If all, is there a sequence to the executions? If you have time to answer, thanks.

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      They would all fire, I've sometimes used inputs that are specifically tied for hand/finger animations. I'm not sure about the sequence of execution though.

  • @magdalenak335
    @magdalenak335 2 роки тому

    Heyy!! thank you for this tutorial! :) I have an issue with it :( On Link everything works properly, but once built fro oculus quest 2, the controllers(only buttons) do not respond :( Do you know how I could fix it?

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      In the XR Plugin Manager, there should be a tab for your Android build. Make sure you've set that up as well.

  • @relivoaddad
    @relivoaddad 3 роки тому

    Great Vid Andrew, are you going to be doing one about getting thumb touch & finger tracking working on OpenXR?

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      Yeah, if it becomes available, not sure about the status of it right now.

    • @relivoaddad
      @relivoaddad 3 роки тому

      @@VRwithAndrew Actually after writing that, I saw that apparently according to Unity thumb touch should work but not the other fingers (not sure about index finger). Unity told me Valve would have to release an extension for this to work.

  • @IneffaWolf
    @IneffaWolf 3 роки тому

    Heya, I've just watched through the whole video and it's cool to see how powerful this can be when it's applied correctly.
    I want to ask, you seem to be using Index controllers, so do you know of any way to get the finger tracking data with Index?
    I can't figure out a way to have VR hands with the correct hand positions with OpenXR. Ideally in future it would be cool to be able to bind certain things to certain hand gestures.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      Yeah, unfortunately, that's only available through SteamVR/OpenVR at the moment. That's as of my most recent knowledge. I do hope it gets added in the future.

  • @djtyros
    @djtyros 2 роки тому

    Hey I'm looking to hold down a button on my controller (Maybe the grip or index button), to drag around a plane object which stays where it is, when I let go.. Like dragging a window around in windows.
    Do you have any recommendations for that? Thanks

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      You can use a Grab Interactable with the gravity turned off, and the throw functionality. You should be able to press and hold to grab/drop the object.

  • @etmasikewo
    @etmasikewo 3 роки тому

    The code was a bit too much but I'm starting to get the hang of it. Could you put the output before the start of the video/coding? It made more sense when I realised what you were implementing.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      Gotcha! I used to have comments outlining the code before actually doing the implementation. But, I seem to forget something when I do change up the video style.

  • @joel352
    @joel352 3 роки тому

    How would you adjust the script so that you can only toggle or change color while it is being hit by the ray? So not every action causes the change?

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      That's when you would need to go through the Inputs on the Controller. It isn't super easy to make a custom controller. But, there may be a simpler alternative way of having the script check for a target interactor, and it's hovering or selecting an object. Then doing some additional functionality.

  • @d7a6on.
    @d7a6on. 3 роки тому +2

    Early gang

  • @OmegaRayblade
    @OmegaRayblade 3 роки тому

    Hello, Andrew! A few questions:
    1. Do you use OpenXR for Vive controller in this video? I've tried HTC Vive with OpenXR and it only been a bunch of errors at launch in Unity console. Oculus and Samsung HMD were working fine with native Unity plugins/checkboxes.
    2. So what you've shown lets us use any button on our specific controller for our VR purposes. Is this your workaround for pretty limited number of buttons in XR Toolkit controllers? If I remember correctly, XR toolkit controller only has eyes, axis, grip, trigger, UIpress and haptic by default. If we want full functionality for more buttons, would you suggest inheriting from XR controller class and adding new button actions? Or better not bother with it and just subscribe to action events?

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      I just use the Index Controller for this video. But, I've mapped Vive/Index controllers for input in a single project.
      It depends upon the context, the method I show here is fine if you're just looking for some basic functionality. If you're trying to add an additional Active or something to an Interactable. That would need a custom controller. I've done for another project, but it's not super intuitive.

  • @petacrdi
    @petacrdi 2 роки тому

    Each controller has an Action Map named XRI LeftHand and XRI RightHand. Each Action Map has a list of Actions, like Select, Move or Activate.
    Do you know how to get the Move of one of these controllers? Can you point me in the right direction with docs or something, please?
    I tried obtaining the XRController or ActionBasedController components from the GameObject but there is no Move property or action or whatever it is named.
    Thank you! Great channel by the way!

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      You wouldn't be able to get it through the controller easily. It would probably be more straightforward to reference the Input Action Asset directly.

  • @brendanfusik5654
    @brendanfusik5654 2 роки тому

    MY CommonUsages doesnt look at all similiar to yours. D you know why this might be?

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      I'm not sure, I don't know if there have been any big changes to the Input System. What version of Unity are you using?

  • @mrmorphic
    @mrmorphic 3 роки тому

    These videos on XR toolkit are perfect! As a newbie to unity, it's really hard to figure this out from docs (which are sometimes obsolete), so thank you, you've saved heaps of time. One question though: I have a frustrating behaviour where when the game starts, most of the time the HMD looks at a fixed point with two lasers coming out of each eye. It doesn't matter where I move my head, the visual is identical, and not tracking. It's like it doesn't reliability start. When I take off the headset and look at the PC window, it is usually semi-functional, in that the headset still points at a fixed location, but at least the controllers and their laser pointers work. Occasionally it does work correct to start. Does this sound like I've set up something wrong? Any tips are what to look at?

    • @mrmorphic
      @mrmorphic 3 роки тому

      I should add that its an HP reverb, windows mixed media. Works fine on all other VR apps.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      @@mrmorphic Yeah, unfortunately I don't have much first hand experience with WMR. I can only say to double-check your Unity settings, and try giving OpenXR or the Standalone WMR settings a shot.

    • @mrmorphic
      @mrmorphic 3 роки тому

      @@VRwithAndrew all good. Playing around with it, seems to be related to input system. In WMR you can toggle inputs between desktop and VR, and it works once I started playing and toggle it. I'll see if there is a way to force it.

  • @danieljohnstone77
    @danieljohnstone77 3 роки тому

    Hi Andrew, Would you be able to do a video on getting the Vive trackers working in this new system, I am really struggling to get the trackers working.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      I've seen this request a lot, and I still need to look into it. It may be more beneficial than I expect. However, I only have one tracker so I probably can't go into too much detail on it.

    • @danieljohnstone77
      @danieljohnstone77 3 роки тому

      @@VRwithAndrew hi and thanks for the reply, even getting one working would be highly beneficial and I would appreciate it so much.

  • @RickMcMichael
    @RickMcMichael 3 роки тому

    If I wanted to update my scripts but only change as few lines as possible... what would be the quickest way using the "new input system" to get the status of Left Controller Trigger Button etc? I have an entire system that needs updating now, and it updates that status of buttons in one function and fires events ( very complex but very fast) and I would prefer to keep this vs Unitys system as it seems theirs bogs my system down a bit more.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      There are a lot of different ways of doing it. You may want to look at this Quick Start guide to see what option may work best.
      docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/QuickStartGuide.html

    • @RickMcMichael
      @RickMcMichael 3 роки тому

      @@VRwithAndrew Any chance you are building a VR Platform to sale on Unity Asset Store? xD
      btw good advice going out in Unity Discord :) sure a lot of people appreciate it

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      @@RickMcMichael Maybe at some point! I do have a project on Patreon that I've been keeping some projects updated with. But, I have a lot of other projects I'd like to explore till XR Toolkit releases officially.

  • @_Garm_
    @_Garm_ 3 роки тому +1

    a stupid question, does this work on Oculus quest as well ? im thinking openXR is valves API ?

    • @TeaZ
      @TeaZ 3 роки тому +1

      The nomenclature is a little confusing. Valve's API is OpenVR, not to be confused with OpenXR; This is the Khronos Group's standard for VR and AR. The goal of OpenXR is to allow developers to target many devices. OpenXR is supported on both the Quest and Index, and on many other devices, and probably many more to come. That's my understanding of it all, I'm not very experienced.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      This is true, OpenVR now also follows the OpenXR standard from my understanding.

    • @_Garm_
      @_Garm_ 3 роки тому

      @@VRwithAndrew & ​ @Tri Stan , thank you guys, for clearing it out :)

  • @aeryxx-
    @aeryxx- Рік тому

    how do i deal with holding buttons?

    • @VRwithAndrew
      @VRwithAndrew  Рік тому

      You can try looking into isPressed, or in the Input Action Manager, you can add an Interaction to an Action called "Hold".

    • @aeryxx-
      @aeryxx- Рік тому

      @@VRwithAndrew ive tried adding the hold interaction but it seems to not work, heres the script im using
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine.XR.Interaction.Toolkit;
      using UnityEngine.InputSystem;
      using UnityEngine;
      public class EchoMovement : MonoBehaviour
      {
      public Rigidbody playerRigidbody;
      public InputActionReference boost;
      public ActionBasedController controllerRight;
      public ActionBasedController controllerLeft;
      public float boostForce;
      private void Awake()
      {
      boost.action.performed += BoostRight;
      }
      private void OnDestroy()
      {
      boost.action.performed -= BoostRight;
      }
      private void BoostRight(InputAction.CallbackContext context)
      {
      Vector3 targetDir = controllerRight.rotationAction.action.ReadValue() * transform.forward;
      playerRigidbody.AddForce(targetDir * boostForce * Time.deltaTime);
      }
      }
      the hold interaction is on the action, not the keybind and is set to button with inital state check off

  • @danielgalli6760
    @danielgalli6760 3 роки тому +1

    Nicee

  • @wolf2110
    @wolf2110 3 роки тому

    That was helpful! May I ask how old you are?

  • @yasarbaba2413
    @yasarbaba2413 3 роки тому

    🖐️Can you make a video tutorial on 'using hover' in the next video?💯
    📍The reason: we cannot run mause codes at VR.
    🥽You can also give a hint.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      Ahaha, probably need a bit more info on what you mean by "Hover".

    • @yasarbaba2413
      @yasarbaba2413 3 роки тому

      @@VRwithAndrew :))) There are many tutorial videos on UA-cam. Almost all of these are mouse-operated codes. The same does not work in VR Touch Controller. :) Or I could not run it. :)))