Complete VR Body Setup - Arms and Legs IK with Hand Animation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back everyone to America Blue's new VR tutorials in unity so I previously made a four part tutorial series on how to make a full body in VR on my main YouTube channel villain and today I have the pleasure to share with you this video which will not only resume all of the series in a single one but show you a better and most robust way to do so with Armor's ik procedural woke and ends animation but before you know the drill feel free to support my work on patreon where you will be able to find the source code of all of my tutorials and exclusive content like this special overview of how I recreated beat saber in unity using only chat GPT but now without further Ado let's get started okay so I'm inside a very simple Unity project I already made a VR setup with and presents using the MTX Auto kit now of course this tutorial can work with any VR SDK you will only need the position of the ends and of the head but the first thing that we are going to need is of course a 3D character model so what I'd like to do is go to mix ammo there you can download any character that you want in my case I'm going to download this one so let's click on download select F bakes for Unity and click on download again now once it is download you can simply drag it in the project folder of your Unity project and there you go at this point it should looks like this now little tips if you have no material showing on the character you can actually go to materials and in location select use external materials next make sure that the animation type of this Avatar is set to humanoid you can do so here on the rig tab then on animation type humanoid and then click on apply but now that's down we have a nice looking character in our project that we can drag in the AR key there it is is we can move it to the side like this and we are now ready to use it as our own VR body okay so a naive way to make this character follow our controller will be to go in its bone like here and their spine and for example move the hand bone to the controller position but as you can see there is just one little issue well the rest of the arms does not follow so to fix this we are going to use inverse kinematics now to start with kinematic we need to go to Windows package manager Unity registry and search for animation rigging package there it is we can select it and click on install once downloaded we include the package manager and if we select back all character that we can rename VR character RK let's go to the animation rigging tab that was recently added and select bone renderer setup as you can see this has added some Gizmo to display the bones of our character and that we will use to easily select them from the scene view by the way you can even change its color here but now let's get started with the arms ik for this we need to add some constraint to the rig that we can see here I'm going to create an empty children to the character ik that I can rename VR ik rig and then add a rig component to it now as you can see we have an error showing so to fix this let's go back to the character ik add component and add a rig Builder finally we can then drag the VR ik rig to the rig Builder there you go now we are ready to add some new constraint I'm going to create a new empty game object call it right arm ik we can then add a new component called to bones ik to set up this component we first need to click on one of the first bone from the right end this should make you select this mix ammo rig right hand game object so let's now go back to the right arm ik drag it to the tip and here is the real magic now let's right click on the component and select auto fill from tip transform and as you can see this as autocomplete the two other bones so the root and the mid but also added two empty game object for the Target and the hint next we need to play them correctly I'm going to select the target press on Ctrl key and then select the mix ammo right hand from earlier and go to animation rigging align transform and here it is as you can see this has automatically placed the target to the hand position now for the hint this is used to say in which direction the arm will fall so what we can do is simply reset its component then place it below and be on the character something like 0.5 minus 0.5 minus 0.5 and there you go now if I click on play oops as you can see all character is now taking a weird position and this will be fixed later on so don't worry about it but if I move the right arms Target the rest of the arm follow who this is so cool but you know what we have to do now if we leave play mode we simply need to repeat this again but for the left arms [Music] there you go now I have another two Boon constrain but for my left arm this time and as you can see my left arm Target is placed on the left and position and the left hand behind the left arm at -0.5 minus 0.5 and minus 0.5 and if we click and play there you go as you can see both our arms are controllable simply using the target that's awesome but now one big question is on everybody's mind how can we endure the legs and we actually have two ways of doing this the first one is animation based this is the method that I covered previously in my tutorial series on how to create a VR body which use a working animation and add a Nike layers on top to bend the knees in the animation but for this tutorials we are going to use the second method which I think will give us better result and for this method it is to create the old animation using ik now for this we are going to use a script from the unity channel that made a similar system for this working robot anyway the first thing we need to do is add two bones ik for both all legs as well which you already know how to do from the arm setup so let's do a little bit of video speed up magic and see you in the future [Music] [Music] there it is so as you can see nothing new I added two new bones constrained with this time the foot bone and position the hint of both legs in front of the body to make them bend in the good direction so if I click on play everything works as expected and I can control the legs as well with its two Targets Now to create a working emission using this ik I'm going to select both leg Target click on ADD components and add a Nike Foot solver to it now as I told you this script is from the unity walking robot tutorial that you can find in the description below and I highly encourage you to go watch it if you want to learn how this script is main but the good thing is you will be able to find the link to download this script as well in the description but make sure to leave a like on your way there anyway now to set up this script let's drag the VR character ik to the Buddy set the terrain layer to default by the way if your vrb has a capsule collider make sure to set it to a different layer and to not select it right here but now I will only select the right foot and drag the left foot in the other foot variable and then do the same again but for the other foot and now if I click on play as you can see if I select the VR character ik and drag it down or up the feet stay at the ground and the knees are bending which means that it is working but now the most important if I move the character forward as you can see it move with a walking cycle that's so cool of course it is not perfect in no means but I think it already give a pretty decent result now the only problem is that the feeds are rotated but we can fix that if we go to the foot rotation offset and in my case I found out that a value of minus 120 180 would work there you go now that in play mode of course so let's leave play mode we write these values to keep them this way and there you go now at this point we can control both arms and legs what's missing is obviously the head and luckily this phone is the easiest okay so for the add ik I'm going to add another constraint called Head ik we can add a new component called multi-parent constraints and for the constraint object we need to go to the character rig go under neck and drag there the head bone then for the source let's create an empty child of the head ik cold head Target we can now go back to the constraint and drag the head Target in the source object there you go at this point you should know the next step which is set the head Target position on the rig so let's first select the head Target then the head bones go to animation rigging package align transform beautiful and there it is if I click on play as you can see it works when I move and rotate the head Target the add follow as as well that's awesome and we can now control all body parts so what's left is to make them follow the controller and the VR headset of or VR big okay so in my latest trial series on how to make a VR body I made a script to make the three Target follow the VR controller and the VR headset so to save me some time I already added the script in this project and you as well will be able to find it in the description below now for this script let's go to our character add component and add the ik target follow VR rig script now if I open the script in Visual Studio as you can see it's not that complicated in this late update I will code the map function for the three ik Target to make them follow the corresponding VR rig position but also it will move the root character as well to make it follow when all VR headset move anyway now let's go back to Unity to set it up for the ik targets of the head let's drag the head Target now for the Left End the left hand Target and for the right hand the right hand Target okay finally we are now missing not the ik target but the VR Target which are on our VR rig here but little trick instead of directly dragging them here I'm going to create some empty game object as children of them to help calibrate the body later on so let's select the main camera the left hand and the Right End right click create empty we can call the first one head VR Target then left hand VR Target and then right hand VR Target and then we can drag them in the corresponding setting on the ik follow VR recomponent beautiful now let's have a look at the Brazil by clicking on play now as you can see the head is following our feet which is kind of weird but if we go to the ik Target follow rig we can actually change the head position to minus 0.54 on the y-axis to fix this next as you can see if I move the right end and the left hand it seems to work but we have the end of the Avatar that are offset from the position of our hand in real life that are represented by the blue hand now in my case I found that for the left hand a value of -0.046 minus 0.032 and minus 0.112 would work with a rotation of 0 90 98.5 so before continuing let's copy this component leave play mode paste it back and don't forget also to go to the VR character rig to set back the position offset on the y-axis to minus 0.50 power finally let's click on play once again and the lighting is to set up the right hand but luckily the right hand should throw something similar as for the left hand so let's paste the same component that we copied before and write Plus 0.046 instead of minus 0.046 and instead of 90 degrees add 100 and 80 degrees oh and it seems that we need also to add a minus value on the z-axis here for the rotation so let's write minus 98 here and there you go now the position seems to match we can copy the component once again leave play mode and paste it back of course we can do the same but for the hand right now in my case I found that a value of 0 minus 0.08 and minus.006 works great and now there you go if we click on Play One Last Time as you can see the position of the Avatar is correctly adjusted and seems to follow our body at the good position that's awesome but the last thing missing is that as you can see the ends are not animated like or blue hands so let's find out how we can fix this okay so let's leave play mode to add animation to the character hand I prepare before recording this video a special animator call the VR rig animator and that I have here in my animation folder on this project so if I double click on it as you can see this animator has two layers one for each end and here four parameters to control the different animation and if I just show you one of the layer the left hand for example it is composed of one blend tree that will use two of the four parameters to select the corresponding animation that you can see updated from these parameters on this little preview on the right and by the way to make sure that the Right End does not overwrite all the animation of the Left End I added an animation mask to each layer and anyway you will be able to download this animator and the corresponding animation as well in the description below but now let's go back to the scene so in the VR character icon for the animator let's set the controller to VR rig animator perfect so at this point the last thing left is to update the value of the animator based on the controller input and for this I have a very simple script that I made previously called animate on input if I open this script as you can see it is very simple I browse a list of inputs and set the corresponding animator value now anyway back to the unity editor let's add four elements the first one will be right pinch so make sure you have to type the name correctly and we need to use a reference and Link it to the right hand activate value there you go now we need to do the same but for the right end with the right select value and now let's finalize everything by doing the exact same thing but for the left end with the left and action oh and something that I almost forgot is that you need of course to reference the animator parameter that you have here so let's drag the animator from the VR character ik to the animator of this animate on input and just like this everything should be ready let's now click on play one last time I promise and there you go guys congratulations if you managed to reach this point it means that you succeeded to make the full via body Avatar with and animation and I mean the result is really really cool of course not perfect you can for example improve the arm pin position or make a better walking cycle with the ik or even make the all-arm twist when we rotate the hand but I think it is already cool like this anyway thank you for watching and a big shout out to my new patreon that will appear on the screen right now so if like them you want to support my work and access the source code with exclusive content you can join us on patreon with the link you will find in the description below thank you for watching and see you soon bye all right thank you
Info
Channel: Valem Tutorials
Views: 37,910
Rating: undefined out of 5
Keywords: valem, valem vr, valem tutorials, virtual reality, VR, vr tutorial, vr tutorial for beginners, vr tutorial unity, unity, unity vr, unity vr tutorial, vr dev, vr development, how to make a vr game, unity xr toolkit, vr basics tutorial, vr tutorial beginner, xr toolkit unity, full vr body, complete vr body, arm ik unity, legs ik unity, procedural walking animation, vr procedural animation, vr ik, vr animation rigging package
Id: v47lmqfrQ9s
Channel Id: undefined
Length: 17min 36sec (1056 seconds)
Published: Sun May 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.