How to make a Body in VR - PART 2 : LEGS

Поділитися
Вставка
  • Опубліковано 20 сер 2024

КОМЕНТАРІ • 99

  • @LordZandaurgh
    @LordZandaurgh 4 роки тому +26

    It used to be so hard to find good VR Unity tutorials, but this channel is like everything I've been asking for!

  • @MKVProcrastinator
    @MKVProcrastinator 4 роки тому +27

    I feel like I've discovered the cornucopia of VR gamedev tutorials.

  • @proclaimedgamers5708
    @proclaimedgamers5708 2 роки тому +5

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class VRFootIK : MonoBehaviour
    {
    private Animator animator;
    public Vector3 footOffset;
    [Range(0,1)]
    public float rightFootPosWeight = 1;
    [Range(0,1)]
    public float rightFootRotWeight = 1;
    [Range(0,1)]
    public float leftFootPosWeight = 1;
    [Range(0,1)]
    public float leftFootRotWeight = 1;
    // Start is called before the first frame update
    void Start()
    {
    animator = GetComponent();
    }
    private void OnAnimatorIK(int layerIndex)
    {
    Vector3 rightFootPos = animator.GetIKPosition(AvatarIKGoal.RightFoot);
    RaycastHit hit;
    bool hasHit = Physics.Raycast(rightFootPos + Vector3.up, Vector3.down, out hit);
    if(hasHit)
    {
    animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, rightFootPosWeight);
    animator.SetIKPosition(AvatarIKGoal.RightFoot, hit.point + footOffset);
    Quaternion footRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
    animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, rightFootRotWeight);
    animator.SetIKRotation(AvatarIKGoal.RightFoot, footRotation);
    OnAnimate();
    }
    else
    {
    OnAnimate();
    animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, 0);
    }
    }
    private void OnAnimate()
    {
    Vector3 leftFootPos = animator.GetIKPosition(AvatarIKGoal.LeftFoot);
    RaycastHit hit;
    bool hasHit = Physics.Raycast(leftFootPos + Vector3.up, Vector3.down, out hit);
    if(hasHit)
    {
    animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, leftFootPosWeight);
    animator.SetIKPosition(AvatarIKGoal.LeftFoot, hit.point + footOffset);
    Quaternion footRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
    animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotWeight);
    animator.SetIKRotation(AvatarIKGoal.LeftFoot, footRotation);
    }
    else
    {
    animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 0);
    }
    }
    }

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

    Valem I love your videos! But I should say that with a little work one could use your custom hands tutorial to create hands, then hide the rigs hands and have the wrists match up haha. I'm sure your pateron is a much better solution though if anyone wants a quick solution I found that worked nicely

  • @swancollective
    @swancollective 3 роки тому +3

    @valem watching you code the hell out of this, is like watching some kind of renaissance master paint the Mona Lisa. How the hell did you get to this level of confidence? Are you figuring out all those lines yourself? This is sometimes so incredibly complex, and after years of trying to learn C# I couldn't do 1% of what you're doing each episode. Just mindboggingly mindblowing.
    LOVE you.

    • @ValemVR
      @ValemVR  3 роки тому +3

      Thanks man but a lot goes to the preparation when making these videos! :)

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

      @@ValemVR Yeah I get that of course. But to come up with that logic in the first place - no matter how much time you got - is still incomprehensible to me. Pure genius. And on top of that so generous. If people like you would run the world, everything would be alright.

  • @mikc869
    @mikc869 4 роки тому +9

    This tutorial is great, as was part 1. The only real problem is that you have used a completely different structure on your rig to the first video. It does not appear to contain the constraints you made in part one, but instead, three other game objects named HEAD, LEFTHAND, RIGHTHAND. This causes a huge disruption in the consistency and flow of information when the video indicates it's a continuation. Thank you for the video though, it is very much appreciated.

    • @d3s4st3r1
      @d3s4st3r1 4 роки тому +3

      It's really confusing and yet I'm wondering why nobody else noticed. Looks like it's an improved version of Part 1 to me.

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

    I would recommend using a layermask and uncheck the playerbody layer.

  • @skyking7864
    @skyking7864 4 роки тому +4

    Would love to get finger tracking if possible, keep up the videos 👌🏻

  • @KentHambrock
    @KentHambrock 4 роки тому

    Another IK video? Sweet!

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

    I fixed The issue with legs going together to fix the issue im gonna paste my code so you can do it yourself

  • @monkeyperson9392
    @monkeyperson9392 4 роки тому +14

    how can we add finger tracking to it?

    • @RobertKvsv
      @RobertKvsv 4 роки тому

      He has a seperate tutorial for this

    • @RobertKvsv
      @RobertKvsv 4 роки тому +1

      @@BezbroGames patreon, unfortunately

  • @Gulguruth02
    @Gulguruth02 4 роки тому

    Awesome! I was hoping for this

  • @yaoling_XR
    @yaoling_XR 4 роки тому +1

    Awesome! I can be my hero in virual reality!

  • @yawdiegamer7098
    @yawdiegamer7098 4 роки тому

    Man, this whole series has been amazing stuff, I have been waiting for, for so long. I love this series. If you ever get time would love to see you do a series if possible on fps arms using this, I got the arms working but hand animation requires a different approach. Also, put the cherry on top in the form of Body physics for the VR body lol. Yeah, I am going to be that guy, but still gonna ask lol.

  • @pureay2700
    @pureay2700 4 роки тому +4

    When i add the animator avatar, my mode just flys towards but past, were it should be in correlation with the head set. If i start without adding the avatar it snaps to were it should be but when i add the avatar it just stays still even if i move the camera, ik targets or controlers

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

    VERY COOL!

  • @corbinxtitus
    @corbinxtitus 4 роки тому

    Thanks man

  • @puff_katashi
    @puff_katashi 4 роки тому

    Thanks you so much for this

  • @chanceslaughter3237
    @chanceslaughter3237 4 роки тому +1

    I found one small problem, my hands don't align because the rig is unable to stretch, so it's assuming the player is VERY short... This makes it look super funky...

  • @mrspiderz9990
    @mrspiderz9990 4 роки тому +1

    can you show how to do like body calibration please.

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

    THANKS!!!

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

    Can you make a tutorial on how to track full body legs in this using vive trackers? I get that we have a walking animation, but I wanna move my legs freely

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

      yes i need that too

  • @bouncycow3010
    @bouncycow3010 4 роки тому

    This is so cool! It really is. Keep up the amazing work!

  • @Blue_Cage_mma
    @Blue_Cage_mma 4 роки тому

    Thanks!!!

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

    my hands don't work they stay stiff pointing forward how can i fix it :(

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

    the legs don't bend when i lower the character into the ground, why is this happening?

  • @elliottthompson8081
    @elliottthompson8081 4 роки тому

    Yes

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

    Can we connect XR Hands and hand tracking with this IK ?? Can anyone tell

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

    Could you attach a second set of hand controllers to your feet to track foot and leg movement? Thanks! Great video. (I know I could get the Oculus pro if i could afford it for leg movement)

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

    can we do it without animation ? bc legs are still inside the ground.

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

    When I move my arms down by my waist, the legs start to go all wonky like they are kicking at my waist. Anyone have any tips or have this same issue?

    • @Nera-whimwhams
      @Nera-whimwhams 3 роки тому

      Same thing is happening to me. I think it is the hands interfering with the Raycast. I tried having them ignore raycast, but it didn't help. I would love a solution to this problem as well. :)

    • @Soul.Gnomon
      @Soul.Gnomon 3 роки тому +1

      I fixed this by removing the mesh collider on the robot

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

      in VR animator controller script, try setting Smoothing to 0.16 in inspecter, worked for me

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

      @@Nera-whimwhams ignore raycast is work for me, becasuse the hands has a collider which will be detected by ray

  • @coinstudiocrosstec8745
    @coinstudiocrosstec8745 4 роки тому

    I'll make a body right now

  • @GamerReality
    @GamerReality 4 роки тому +1

    How much extra performance does this body use for a Quest game, and can i get hand tracking to work with a full body on Quest?

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

    Thank you very much for this great tutorial. I'm a VIVE user and use STEAM VR instead. I found out that if I follow steps in the video, at the end, my Robot would continuously fall under the ground. This got on my nerves. Could you give some solutions to this? Thanks a lot:)

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

      I am not sure if this maybe causes another problem but in the animation you can set the root transformposition of the Y axis on bake into pose.

  • @samialfarra4275
    @samialfarra4275 4 роки тому

    thank you so much . when will you post a tutorial in patreon for custom hands in vr body ?

  • @victorjohansson6455
    @victorjohansson6455 4 роки тому +1

    I didn't notice that the issue is actually in this video and thought it was my project that was the issue. But as can be seen here, the hands curl up, or bend inwards a bit. What's the deal with that? And how would you go around solving it? The hands are not bent similarily in the animations used from what I can tell. And this is quite breaking the whole point of only animating the lower part of the body.

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

      Did you ever manage to fix this? Having the same issue.

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

    Hi Valem or anyone that can help,
    can I use the IK hand setup while also using the animator for moving the legs? Because when I add an animator controller with an avatar my IK hand setup stops working. Not sure what to do to work pst this. Thank you , and awesome tutorials!

  • @franciscoestrada1304
    @franciscoestrada1304 4 роки тому +1

    I can't move Robot Kyle by selecting him when in game mode like you can. I can only move him if i move the OVRCamera rig. When i start game mode, he also jumps a few spaces ahead of where i spawned him. And I've done all the code, but his feet still go through the floor. And i went back over part 2 just in case i missed something, i can't find anything. Can you help me?
    EDIT: Nevermind, I had one line of code wrong, and i didn't delete the OVRCamra rig from when i watched part 1. Without that camera, its working just like in the video.

    • @kingsway.183
      @kingsway.183 4 роки тому

      What line of code was wrong the same thing is happening to me

  • @cyantox
    @cyantox 4 роки тому

    Hey, can you make a video "How to make your own Room in VR"?

    • @blaccy5991
      @blaccy5991 4 роки тому +1

      Use Blender... its super simple

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

    Hey Valen I keep getting an error message that says 'AvatarIKGoal' does not contain a definition,can someone please tell me what I missed😅

    • @Nicole-Keller
      @Nicole-Keller 3 роки тому +1

      Hey :)
      Did you find a solution to the problem?

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

      @@Nicole-Keller i did not unfortunately I chose to go with another temporary method until I knew wich version I would need to use in the end

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

    I am trying to create a player with SteamVR but I cannot add the walking animation to my Robot Kyle, I completed the first demo successfully...to my knowledge. I am not really certain what I am missing.

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

    When I import the animation, and hit play, The play is facing the wrong way

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

    This worked perfectly, thanks Valem ! But still how can we move while having a native standing height over the ground ? I mean, the body follows the vr camera, so the position of the camera define the height we should have while standing. I was thinking about coding a raycast from the vrcamera to the ground, if the size exceed a certain height value, resetting the heigt of the vrcamera to that height value. What do you think ? Is this the best way ? Thanks

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

    I know nothing about coding so could you please help me and my friend on how to make a model from scratch that works well in vr. (That has arms a legs.)

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

      follow a blender tut on how to create full human models that has the appropriate leg, arm, torso, and head bones

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

    Do you think you can make a vr game with full body tracking?

  • @romland29
    @romland29 4 роки тому +2

    Going through this tutorial, I noticed that with a walk animations and the Robot Kyle model... EVEN with the upper body mask, the hands still curl like they are being animated somehow. If I turn off the VRFootIK script and the animator, the hands return to normal. Any idea as to why this is happening?

    • @romland29
      @romland29 4 роки тому +1

      @Plastic Bag Just as a FPS game allows you to walk (lower body) & Aim (Upper Body) at the same time using masking, the same should work with any body part including hands. You don't simply swap an entire animation just because you don't know how to mask something.

    • @victorjohansson6455
      @victorjohansson6455 4 роки тому

      @@romland29 Did you manage to fix this issue? I just noticed the same thing, and it stops me from doing other things to the hands.

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

      Did you ever manage to fix this? Having the same issue.

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

    Hello again I just had a quick question,when I import the walking animation from mixamo to unity I dont get an animated walking preview only blue caution symbol and im not sure how to fix this as I've tried things I red online but they haven't solved my issue

  • @StormyDoesVR
    @StormyDoesVR 4 роки тому

    I tried to create the walking animation and it broke my character's rig, making the whole body fly off to the side, and now after stopping that it says this - UnassignedReferenceException: The variable headConstraint of vr_rig has not been assigned.
    You probably need to assign the headConstraint variable of the vr_rig script in the inspector.
    UnityEngine.Transform.get_position () in :0
    vr_rig.LateUpdate () (at Assets/scripts/vr_rig.cs:45)
    even though the rig works regularly

  • @BrainSlugs83
    @BrainSlugs83 4 роки тому

    The feet never leave the ground during walking. A lot of people use animation curves for that, but it's an annoying problem to solve.

    • @ValemVR
      @ValemVR  4 роки тому

      Yep you can tweak the weight of the ik depending on the distance from the ground for a better result too! :)

    • @pureay2700
      @pureay2700 4 роки тому

      @@ValemVR when i rotate the head on the x axis then the y axis the body does a 180

    • @blaccy5991
      @blaccy5991 4 роки тому +1

      @@pureay2700 thats because you rotate over 90 degrees so its forward is now backwards

    • @blaccy5991
      @blaccy5991 4 роки тому

      @@pureay2700 no now its happening to me

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

    When you apply the avatar, the tracking is horribly off center and the model won't match up, removing the avatar fixes the issue but we lose animations D: any fix so far? @Valem

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

    Is this multiplayer compatible?

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

    is anyone else getting a bunch of errors ?

  • @marksolis9317
    @marksolis9317 4 роки тому

    Are you able to capture and record this kinematic data for later use? Like have a performance in VR. Record data. Have that data played on another model or animator.

    • @marksolis9317
      @marksolis9317 4 роки тому

      Sorry if you mentioned it already in this video. Or that you plan to have it in the next video. Skimming at fast pace multiple videos right now.

    • @ValemVR
      @ValemVR  4 роки тому +1

      Hi no worries yes you can use this and record the frame zt runtime using in an animation using this : github.com/newyellow/Unity-Runtime-Animation-Recorder
      Its quite simple And you will have yourself your own motion capture studio 😊

  • @iplayzdrumz
    @iplayzdrumz 4 роки тому

    At 10:04 the code entered is related to right foot rotation (before copying to the left) - I have this copied exactly but am getting a red underscore on the last written "rightFootRotation" that reads: "Argument 2: Cannot convert from UnityEngine.Quaternion to UnityEngine.Vector3"
    Anyone have a fix for this? Thanks!

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

      the foot rotation needs to be renamed when copy and pasting :) all good
      //Foot Rotation
      Quaternion LeftfootRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
      animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotWeight);
      animator.SetIKRotation(AvatarIKGoal.RightFoot, LeftfootRotation);
      Quaternion RightfootRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
      animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, rightFootRotWeight);
      animator.SetIKRotation(AvatarIKGoal.RightFoot, RightfootRotation);

    • @irinav.8857
      @irinav.8857 3 роки тому

      I have the same issue, how did you fix it?

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

    @Valem My character is still passing through the floor and the knees are not bending. Any idea why I would be experiencing this?

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

      Did you remember to attach the script to Kyle or whatever avatar you have?

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

      i have the same issue aswell

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

      @@reduxf4089 Is your script correct and is your avatar mask correctly defined with IK pass? These two were my reasons for similar problem.

  • @reborok
    @reborok 4 роки тому

    Love your tutorials. I followed this one (multiple times) but once i set the avatar on the animator to be the robertkyleavatar the IK does not work anymore and the whole character freezes in its current position :( could you please help?

    • @ValemVR
      @ValemVR  4 роки тому

      Which version of unity do you use? :) There was a bug with rig avatar in 2019.2.6 I believe

    • @reborok
      @reborok 4 роки тому

      @@ValemVR I'm using Unity 2019.2.17f1.
      Also, do you know what could be the issue that my hand tracking is too low? its perfectly fine in Oculus. Thank you so much for the answer

    • @ValemVR
      @ValemVR  4 роки тому

      @@reborok what do you mean to low? Is there an offset between your real hands and the hand tracking hand?

    • @reborok
      @reborok 4 роки тому

      @@ValemVR Yeah. If I put my hands in front of the VR headset for example. In Oculus I see the controller right in front of my eyes. Yet in unity the hands are at my chest :/ I can't figure out why.

    • @reborok
      @reborok 4 роки тому

      I have no idea what the difference is but I setup a new scene and redid my PlayerPrefab from ground (PlayerPrefab from SteamVR + my scripts) and now it works perfectly fine. Thank you though :)