Building a Hand Poser for Unity XR
Вставка
- Опубліковано 11 вер 2024
- Hello and welcome! Today we're going to be going over the hand poser I've created for Unity's XR Toolkit. We'll be doing an overview of the project, as well as doing a bit of coding for the poser used during gamplay. And to do this, we'll be using Unity 2019.4 and Unity's XR Toolkit 0.10.
GitHub:
github.com/C-T...
Support my work, and get access to source code!
/ vrwithandrew
This is awesome! Super helpful and it provides a much better experience than simply not showing the hand when selecting an object. I messed around with this and was able to make the hands respond to physics too, so now I feel like I have the perfect hand setup thanks to you.
Glad you got some use out of it, Juan!
You always predict the next features I plan for my project. SO glad you tackled this, thank you!
You're quite welcome, hopefully you find it useful!
woah this is exactly what ive been looking for! thank you so much
Happy to help!
Looks great Andrew!
Thanks, Pico!
BEAUTIFUL. Thank you! this is exactly what I'm looking for. I hope it works!
Let's hope! I haven't checked on it recently and is probably do for some XR Toolkit updates.
Nice Tutorial Andrew, thanks! Maybe a part 2 tutorial to explain how to have multiple poses for 1 object depending on where it was grabbed?
Yeah! That's something that should be possible with XR Toolkit.
I just finished the hand animation tutorial and was wondering how to pose the hands..... Thanks again!
You're welcome!
Dear Andrew, thanks again for your incredible skills and for writing this amazing tool!
Just a question: Your custom poses work perfectly, but only if I grab the objects. My hands don't do a grabbing animation when I hit the trigger and there's no object. They remain still, while before they were moving like the regular Quest hands.
Is there something I can do to get this standard behavior back?
Can explain that a bit more? Is this for like static interactables?
@@VRwithAndrew thanks for your quick reply! I just mean the very basic and common functionality, that the hands make a gripping motion whenever the trigger is pressed, independent of any objects in the space.
Like the standard oculus hand models.
@@swancollective Ohhh, gotcha! Yeah, I have another series on how to map the inputs to a hand model as well. I believe it's just called XR Hands. At some point, I'm hoping to be able to combine everything + IK Arms or similar.
@@VRwithAndrew Yes, my current hands are the result of your incredible tutorial "Custom Hands for Unity's XR Toolkit". Those are animating perfectly, but they won't work with custom poses, right?
Is it currently possible to combine animated hands with custom poses, i.e. this tutorial with your custom hand tutorial?
Basically, I like to attach your "HandAnimator" script to the custom-pose-hands of this video. Any help highly appreciated!
@@swancollective Yeah, that's possible! It certainly takes a bit of know-how to set up the same asset working for both. You'll primarily need to write logic that prevents the HandAnimator from doing anything while there is an active Pose occuring.
Thanks for doing this and making it public
I do what I can!
This is fantastic! I'm sure it's going to be a feature unity will be adding soon. But for now this rocks!
Thanks, Hammed!
unity should just take over this solution, its perfect
They never did this right?
Do you need a specific plugin to add 'Pose Container (script)' to your project? It's not showing up for me.
No, it should've been in the Github project and it's not there for whatever reason. Which, I'll fix that today! It's a really simple script, so you can go ahead and make a script of the same name.
@@VRwithAndrew Oh awesome! thanks so much!
this is dope i'll probably use this later
Hello thanks for this nice Video. But i have Problems. Can you help me please. If I Grab my own model the Rotation works but the Model is far away from the Hand and the attachments to change doesnt help. And the next question is can i change the Model of the Hand because now it doesnt work.
this is developer gold lol thank you so much
You're quite welcome, Brian
Cool love it. Amazing explanation
I hope you found it useful. :)
@@VRwithAndrew yep can you add a video about implementing AR like that?
@@yudanaim6849 You know, I may look into doing some AR stuff this year. I haven't done it in a while, so I'd have to learn a bit.
@@VRwithAndrew because of covid19 people afraid putting helmets that passed hands. But AR is with their own devices
I know it’s been awhile but is this available for a commercial game or do you own it? Either way this looks cool don’t know how xr has not made this yet
It's technically since I made it. But, it's more/less available for whoever wants to use it for their project.
Hi dude, thank you so much for helping me with this Pose Provider tool! I'm trying to implement it in my physics based VR app. A question, is there a way to organize the object hierarchy and components to get more than 1 Pose for a single object?
I'm in, is there a correct way to organize the hierarchy in order to have multiple pose providers for a single object, and apply a pose depending on the area/part of the object you grab?
It's possible! But, I'm not sure if there's an elegant way of doing it. I've seen a lot of people use multiple pose points, then do a distance check when the object is selected to find which pose/attach they should use.
I know XR Toolkit is considering dynamic attach points for grabbing, so that may be something in the future that makes it nicer.
I am trying to use this tool for the Unity 3D 2021.3.19 release but unfortunately it does not work.
Amazing Andrew, thank you so much!
You're very welcome, Lucas!
hey, i recently updated everything i could and when i imported your files into my scene i got an error in the gameplay hand script about the "interactable" on lines 27 and 36 being depreciated and "interactable object" being the new version, i did this but when i switched i got another error reading as follows:
error CS1061: 'IXRSelectInteractable' does not contain a definition for 'TryGetComponent' and no accessible extension method 'TryGetComponent' accepting a first argument of type 'IXRSelectInteractable' could be found (are you missing a using directive or an assembly reference?)
i have no idea what to do about this, could use some help
Hello, it is possible to behave the opposite way intended? like when I want to use a handle for example, I don't want the handle to come to my hand, but my hand to go to the handle, I'm messing with the scripts but couldn't not get to work :/
Not in its current state, I only have it to work with grabbable objects. It would need some additional functionality to move the hand to the interactable instead.
wonderful bro
Thanks, homie
This is amazing and you're doing an awesome job I'm just starting off and am a little familiar with unity and c# also I'm running a Odyssey wmr headset and was wondering where I should start in your headset ( I also own an old vive fyi though it's not set up )
If you already have the WMR stuff either headset is most likely fine. I'm not sure when it comes to input though. I don't have much experience with WMR headsets.
Hey Andrew, I have a question that I'd appreciate your insight on, I want to do VR dev with Unity, I bought my Quest 2, I can run my scene build and throw a sphere lol, but when it comes to semi-advanced stuff like making hand prefab fingers move, it's pretty tough to wrap my head around how to actually script this in Unity and effect the actions/effects I want to emulate, to add to things it seems like the Unity VR ecosystem is changing so quickly, like you mentioned at the start of this video you're using "device-based" XR rig, not action-based, but I believe action-based is Unity's intended input system for VR going forward, so I want to do this doing that obviously, but I can't even discern what you're doing here that is "device-based" here, to get to my question, if you were in my shoes (new to Unity and VR but not programming (I am a full-stack web dev w/ knowledge of C#)), how would you approach learning Unity + XR development at this moment in time? It seems like every course is outdated (even on Unity Learn), documentation isn't being updated or is vague, dev environment set-up is constantly changing, do you think it might be better to just learn how to create traditional Unity games and then wait for the VR ecosystem to mature? Or is the nature of VR dev so different it's best to just learn Unity and VR at the same time and tough it out, are there any really good courses on fundamentals you think aren't outdated? Thanks for reading and keep up the awesome videos
It's best to learn the basics of Unity before getting into VR. There's just a lot of additional engine knowledge that's assumed you know already.
XR Development is getting close to a point that it shouldn't be changing all that much for a while. XR Toolkit will most likely hit 1.0, and Unity will most likely be releasing an updated Unity Learn course.
Also, note that the majority of what you're seeing here is still technically in Preview. But, even in its current state the amount of functionality you get is much better than what it was previously.
@@VRwithAndrew Hello Andrew great video! One year is around, can you give an updated answer to what you have responded one year ago? I am with Unity since 5.6 and decided to go into VR. Any suggestions to save precious time?
@@TheGamerzXChannel Pretty much still valid, I would just recommend using Unity 2020.
Hey. Just downloaded github files. I followed all steps of setup VR hands on this video. But, when testing in VR, hand pose does not working. What I need to do extra to make pose working in VR?I am complete beginner and want to learn VR development. Thanx
Can you make a video for oculus driver configuration?
I can't get the x y buttons to work.
How can I let the viewer know that the viewer is on the table and pause the game?
thank you
Why are the hand models missing the "Target Interactor" field?
Is it not showing in the Inspector? Either make sure that the variable is Public, or if it's Private use the [SerializeField] markup as well.
Thank u so much. Just a quick question. U already had a video on moving hands using velocity. I wonder if that video and this video can be combined? Could u please differentiate the two. Sort of confused. Thanks again.
This is just for showing the hand in different states/animation when holding objects. The hand velocity is actually for how the hand itself moves to follow the controller. They can most likely be combined, but that's probably a whole thing that I'd need to do on my own before describing how to do it.
VR with Andrew got it. Thank u so much for replying 🔥
Hi Andrew ! Thanks for this amazing tutorial and script, it work perfectly !
I'm currently designing a VR game and that would be amazing if the hands can move along with velocity tracked objects. I know it's been more than a year but is there a easy solution to maybe attach the hand pose as a child of the grabbed object instead of the hand prefabs ?
Thanks again for this amazing content !
Unfortunately, I don't have a solution off the top of my head. It's something that I'm looking at now.
@@VRwithAndrew Amazing ! Maybe a next tutorial on the channel ? :D
If you find something, I'm interested to know what you came to !
Hey is there anyway to use the hand poser but also having a distance grabbing like thing, like boneworks?
In theory! Since it hooks into the selected events, it should work just as well for the ray interactor.
I remember, I used to plan for a future game and how a grabbing system would work, so on pickup, the point would go to the hand, and the hand would pose into a fist and when the finger hit something it would stop. So no matter what you grab you wouldn't have to make individual animations. Now that I am actually a game developer, I have an idea on how I could code that. However my PC is broken. But I can still collect information while I wait.
Great stuff
Thanks, Ted!
Hi Andrew thanks for the tutorial. i see the hand and object always lines up when pose is created but i noticed that the offset from controller to hand needs to be different for different controller manufacturers. do you know if there is a list of offsets/angles so all controllers always lineup. its especialy noticable when holding a gun , oculus, vive, index etc all hold the gun offest and angled in different ways.
This is correct, the biggest difference is between Oculus and non-Oculus controllers. Unfortunately, there isn't a common resource at the moment that defines these differences.
Hey! Is it possible to use this Plugin in a Full body humanoid? Thanks
Potentially, I've never done it. But, I imagine once you get the joints setup it may work.
Not working for me, there is no Pose Container component that can be added to the 3d object, any ideas?
You either don't have the entire project or if you're using an existing project didn't copy over all of the files.
You can see here that's in included in the template on Github,
github.com/C-Through/XR-HandPoser/blob/main/Assets/_HandPoser/Scripts/Pose/PoseContainer.cs
Worked great! The only problem I have is with imported models. When I import a model it will do the preview hands based on the transform location and when I grab it, it will do it relative to the pivot point of the object (on a gun the grip). Because of this it is difficult to get the correct position. Do you maybe know a way to fix this?
Google says to put the prefab in an empty game object, but the pivot will then not change
I can't recall exactly, it's been a while. You may want to actually want to change the code in ApplyOffset within the GameplayHand. For the RotateAroundPivot, you can try changing that to transform.position.
Why, when the "XRGrab" component has the "kinematic" parameter, does the object in the hand begin to go beyond its limits when moving?
That's more/less how physics movement is applied. It kinda lags behind by a frame.
@@VRwithAndrew how can this be fixed? Do I need to change the "xrgrab"code?
@@nikitatim5379 I believe I mention this in the video. But, it's why I use the Instantaneous tracking mode. You'd most likely need to change how the project handles hands. I'm not sure exactly how I would do it.
nice!
Thank you!
Would it be to hard to use this Hand Poser in the OpenXR? (I have a HP Reverb)
I don't think so! I'm hoping to revisit the project again soon to implement it into one of my larger projects.
Thank you very much for this tutorial! I would love to use this in our uni project but it seems the onSlectEntered function is deprecated in the new toolkit version.
It says to use selectEntered instead, but I cant figure out how to use it instead. Do you know a quick workaround for this?
The newer functions use Event Arguments rather than single interactable or interactors. I cover this in my Bow and Arrow update video.
ua-cam.com/video/H0xTz4JtWiI/v-deo.html
@@VRwithAndrew Thank you very much for the tip! I am still quite new to unity vr and the xr toolkit.
So I basically tried (from 11:04):
private void OnEnable()
{
// Subscribe to selected events
targetInteractor.selectEntered.AddListener(TryApplyObjectPose);
targetInteractor.selectEntered.AddListener(TryApplyDefaultPose);
}
private void OnDisable()
{
// Unsubscribe to selected events
targetInteractor.selectEntered.RemoveListener(TryApplyObjectPose);
targetInteractor.selectEntered.RemoveListener(TryApplyDefaultPose);
}
private void TryApplyObjectPose(SelectEnterEventArgs args)
{
// Try and get pose container, and apply
if (args.interactor.TryGetComponent(out PoseContainer poseContainer))
ApplyPose(poseContainer.pose);
}
private void TryApplyDefaultPose(SelectEnterEventArgs args)
{
// Try and get pose container, and apply
if (args.interactor.TryGetComponent(out PoseContainer poseContainer))
ApplyDefaultPose();
}
** also tried args.interactable.TryGet... (still no working as intended, now the objects just snap to the wrist smh)
... but that didn't work. Maybe I still missed something or just dont quite understand whats going on. Help MUCH appreciated! :)
@@xploaded143 If the poses are being applied, that means the events are working. If the object is not the correct place. You'll need to set the attach point of the Direct Interactor with the point from the hand.
@@VRwithAndrew I managed to get it working, sort of :) ... the only issue I faced is that the object for the Pose Container has to be Scale 1,1,1 inside the prefab or otherwise the object will float besides/below/under the posing hand. Managed to work around this issue by only using properly scaled assets in our uni project. Don't know if its a general issue or maybe I messed something up. But really cool stuff, thank you very much for your videos (even though they get outdated quickly with all these new releases). Definitely will stick around!
@@xploaded143 You're welcome! I'll most likely be revisiting this project in the future to update it for XR Toolkit's events, and inputs.
Don't know what happened but when I installed the project it completely annihilated vr compatibility with every unity project, even when I made new ones, uninstalled and installed unity 2019, and even after uninstalling the project
That's not exactly something a project can do. Your Unity or other software may have updated.
I can't seem to find the pose container script, and i do have the XR Interation Toolkit installed
Can someone help me? ")
It's a custom script, you can find the project at the Github link in the description.
Is there something I missed because for me the hand just grabs it weirdly and on the left hand it just goes through the wrist?
Yeah, that doesn't sound correct.
@@VRwithAndrew Ooh yeah i know😂
@@VRwithAndrew I dont know what is wrong though..
@@awsumturtle You haven't setup the gameplay hand script at the end of the video. If you write what's in it, it will work.
@@ciel1189 Oh, I thought it was already written. I'll try it out. Thanks!
I am new to game development in Unity and am very inexperienced, can anyone tell me which files to copy over if i want to incorporate this to a preexisting project?
There are a couple different ways, first I'd make sure you have all of the necessary packages installed. Then, you can copy over the HandPoser folder into the other project, or look into creating a Unity Package where it bundles everything up for you.
Why i dont Have target Interactor on GameplayHand?
What version of XR Toolkit are you using?
@@VRwithAndrew Interaction toolkit? 0.10.0
@@Sija_Men It should show then, just make sure it's marked as Public.
Auto hands has left the chat