Search Unity

FINAL IK - Full Body IK, Aim, Look At, FABRIK, CCD IK... [1.0 RELEASED]

Discussion in 'Assets and Asset Store' started by Partel-Lang, Jan 15, 2014.

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    OK, I see what you mean now..
    In theory it should be possible, but you'd need to solve the IK not on the articulated bodies, but on a copy of the rig without any physics and set up in hierarchical order. Then make a script that converts the localRotations of the IK rig to ArticulationBody target rotations.
    I don't have a great robotics IK solver though. CCD and FABRIK can only solve for the target position, not rotation.
    I have made some custom solvers for KUKA and UR5 rigs in the past though, maybe those can help.
    I also have this package that makes the old PhysX work sort of like an inverse dynamics solver.

    Hey,
    The problem is VRIK holds the chest straight forward normally, but nobody shoots rifles like that. You hold your chest sideways, but VRIK still thinks it should be straight so the hand basically goes into the shoulder. There is not enough data to calculate chest rotation automatically, there are multiple correct solutions given any set of head and hand controller positions/rotations.
    Anyway, people stand sideways when shooting rifles. That's exactly what "Root Heading Offset" was added to the Spine settings for. So when you have the rifle held with both hands, set ik.solver.spine.rootHeadingOffset to something like -45.

    Another option would be to use a "Chest Goal" transform to turn the chest (and set "Chest Goal Weight" to 1 in Spine settings).

    Best,
    Pärtel
     
  2. germanban

    germanban

    Joined:
    Jul 8, 2018
    Posts:
    12
    Hey! Was that last reply meant to answer my elbow issue instead of Dmeowmixer? I actually noticed that the root heading offset did solve that issue as it comes from the hand being too close to the shoulder. I was thinking of making the game recognize if the hands were holding a weapon with 2 hands, get the distance from the trigger hand to the head, and increase the root heading offset gradually when it got above a threshold.

    Thing is, wouldn't that be what the "rotate chest by hands" slider should do? (as so far that slider seems to do nothing for me). Still, gonna try the root heading offset method!
     
  3. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    @Partel-Lang I think this reply was meant for @Jorlman

    My question was something different.
     
  4. labtraining

    labtraining

    Joined:
    Feb 28, 2019
    Posts:
    8
    I'm also having trouble getting the "rotate chest by hands" setting to do anything. My goal is to have the chest loosely rotate around the y-axis as the user moves around, but I don't want the chest to tilt forward/backward/left/right with the head. Is a "chest goal" the right way to handle this? I think I'd rather the chest follow the hands than just the head, so the user can still shake their head without affecting their body.
     
  5. lev-miyamoto

    lev-miyamoto

    Joined:
    Oct 15, 2020
    Posts:
    4
    I'm sorry for asking the same question over and over again.
    FullBodyBipedIK is attached to
    I would like to make it so that both hands of the object attached to the FullBodyBipedIK are attached from the script, can you tell me how to do this?

    I can do it from the Scene view, but I don't know where to change it after I get the FullBodyBipedIK component.
    Specifically, in the following video, from 0:57 to 1:10
    This is the part where the hand is pulled and the leg is extended.

    I've been struggling for two days trying to figure out how to change this from the script.
     
  6. germanban

    germanban

    Joined:
    Jul 8, 2018
    Posts:
    12
    To achieve what you want I'd first check out you have a generous "max root angle" (so you can freely rotate your head before your body "follows), and also near-to-zero "neck stiffness" and "body rotation stiffness" (so when you look back the body doesn't go back too like you had a stick taped to your back).

    About the chest turning by hands thing, I finally achieved what I wanted with a script averaging distance to the headset and modifying the "root heading offset" by using an inverse lerp that activates from arond 35 cm to 15 cm; but it only activates when using long weapons (so the body twists as if aiming when you put the scope up to your eyes, and it depends on which hand you're holding the rifle with -also would average if you're holding 2 rifles at once hah)

    That last thing maybe you don't want to use; just try the things on the first paragraph if you're looking for the body to feel "looser" from the head. Also do try reducing the head clamp weight; while it might seem bad to "unlock" the head rotation from the target, you can actually get away with even 0.5 before you start noticing, and it might give you a lot of leeway to work with the other values before stumbling into visual weirdness or camera clipping issues.

    EDIT: about the chest goal, I don't really like it using it outside of having an actual, tracked chest goal for it to follow. I've tried setting up different systems with a "fake" chest goal to more precisely guide the chest to where I wanted to but, while it works on the surface, being VR you have to keep adding and adding corner case situations until you end up with a complex mess; so better try and solve that with the given parameteres lol
     
    labtraining likes this.
  7. lev-miyamoto

    lev-miyamoto

    Joined:
    Oct 15, 2020
    Posts:
    4
    I'm sorry.
    I was debugging after setting a breakpoint.
    Solver has a parameter called "effectors", and I found that
    By moving the coordinates of the right hand and left hand, I was able to center the direction of the pull of both hands.
    I'm not sure if this is the right way to do it, but I'll let you know.
     
  8. copperrobot

    copperrobot

    Joined:
    May 22, 2013
    Posts:
    69
    Hey, got an issue with 'lookatik' - the eyes appear to be offset by 90 degrees, leading the character to look off to one side and if the clamp is set low enough... rolling their eyes sideways into their skull.

    Is there a way to offset the rotation of the eyes? Thanks!
     
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Oh, sorry, stuff gets confusing when a new page turns in this thread..

    That script I suggested is now VRPuppet.cs. Import the "VR Boxing" demo from Plugins/RootMotion/PuppetMaster/_Integration, it's in there.

    About the shoulder rotation, it's not actually the shoulder bone that is twisting when you rotate the hand, it's the upper arm bone. I think you should try adding TwistRelaxer to the upper arm bone. Assign the upper arm itself as it's Transform (can leave parent and children empty). Set Weight to 1 and Parent Child Crossfade to 0. Also assing the "IK" slot.
    TwistRelaxer runs after VRIK and lets you adjust the twist angle of it's Transform. Is Parent Child Crossfade is 0, the twist angle of the Transform will be locked to it's parent (shoulder), 1 to the child (forearm).

    About "Rotate Chest By Hands", it does work, but it's effect is quite subtle. For example play the "VRIK (Basic)" demo and move the Pilot's hand target behind him and back, you'll see the chest rotate with that. Set Rotate Chest By Hands to 0 and the chest will stop turning along with the hand.

    There is also ik.solver.spine.chestRotationOffset that you can use to turn the chest by script. Will have to set it every frame as it resets to Quaternion.identity after each solver update. For example this piece of code:

    Code (CSharp):
    1. public VRIK ik;
    2.     [Range(-90f, 90f)] public float chestOffsetAngle;
    3.  
    4.     private void LateUpdate()
    5.     {
    6.         ik.solver.spine.chestRotationOffset = Quaternion.AngleAxis(chestOffsetAngle, Vector3.up);
    7.     }
    would give you a parameter similar to "Root Heading Offset", only it would turn the chest instead of the entire avatar.

    To have the player be able to shake their head without moving the spine much, set "Body Rot Stiffness" and/or "Neck Stiffness" to 0 in the spine settings. Also might have to increase "Max Root Angle".

    Hey,
    Yeah, those little blue squares represent the effectors. For example to move the left hand from script:
    ik.solver.leftHandEffector.position = something;
    rotate:
    ik.solver.rightHandEffector.rotation = something;
    Also make sure you have position/rotation weight:

    ik.solver.leftHandEffector.positionWeight = 1f;

    Alternately you could just assign a gameobject into the "Target" slot of any effector in the FBBIK settings and just move that gameobject and the effectors will follow.

    Hey,
    LookAtIK samples the pose at Start to find out which axis of the eye bones is pointing forward. Make sure the gameobject you attached LookAtIK to has it's positive Z axis pointing towards the direction that the character and it's eyeballs are facing.

    Best,
    Pärtel
     
  10. copperrobot

    copperrobot

    Joined:
    May 22, 2013
    Posts:
    69
    The eyes are pointing forward. These are characters from Character Creator, so I'm not sure how I would alter it. The heads do the same, pointing off to the left by 90 degrees.

    It would be handy if there was some kind of rotate offset in the lookat or FBIK or something.

    The alternative is that I come up with a script that takes the position it's supposed to be looking at, creates a clone, matches the intended head position/rotation and then offsets itself by 90 degrees, although that's not really ideal.
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,

    Code (CSharp):
    1. foreach (IKSolverLookAt.LookAtBone eyeBone in ik.solver.eyes)
    2.         {
    3.             eyeBone.axis = eyeForwardAxis;
    4.         }
    Have to run that code after LookAtIK initiates though, otherwise it will overwrite it.
    eyeForwardAxis is supposed to be the local axis of the eye bones that you want to be pointed at the target.

    Best,
    Pärtel
     
  12. copperrobot

    copperrobot

    Joined:
    May 22, 2013
    Posts:
    69
    Ah great, thanks!
     
  13. lessthanthreewizard

    lessthanthreewizard

    Joined:
    Oct 27, 2019
    Posts:
    16
    hi. I haven't bought the asset yet and since there's no evaluation version I would like to ask if it would be possible to do something like in the video shown here and if it is how hard would it be? thanks!
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,

    If you have some animations for the locomotion and aiming forward, then it's just the matter of adding AimIK on the character, parent it's target to the camera and that's it. If you have turn left/right animations too, can trigger them when looking too far left or right from character.forward.

    Best,
    Pärtel
     
  15. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    Tried to teleport player with VRIK but doesnt work, is placed near the point but not exactly at the point, it is like half meter away. I used solver.reset() in the end
     
  16. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Hey Partel,

    You answered someone else's question in your reply to me.

    I am trying to get my VRIK model to allow the forearm to rotate 90 degrees ( 0 degrees is thumbs up ) in each direction without engaging the shoulder rotation as we can do in real life. Currently, the moment the wrist/forearm rotates, the shoulder will also rotate and move the elbow.

    I think I need to something like the below in IKSolverArm.cs

    Code (CSharp):
    1. if(rotation == 90 ||  rotation<90)
    2. {
    3.   shoulderRotationWeight = 0f;
    4. }
    5. else
    6. {
    7.   shoulderRotationWeight = 1f;
    8.   //Possibly LERP this value from 0-1 to avoid jerkiness
    9. }
    Am I on the right track with this?
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Ah, damn, this part was meant for you:

    About the shoulder rotation, it's not actually the shoulder bone that is twisting when you rotate the hand, it's the upper arm bone. I think you should try adding TwistRelaxer to the upper arm bone. Assign the upper arm itself as it's Transform (can leave parent and children empty). Set Weight to 1 and Parent Child Crossfade to 0. Also assing the "IK" slot.
    TwistRelaxer runs after VRIK and lets you adjust the twist angle of it's Transform. Is Parent Child Crossfade is 0, the twist angle of the Transform will be locked to it's parent (shoulder), 1 to the child (forearm).

    Hey,
    Maybe the offset comes from you having moved physically away from the center of tracking space?
    Try using delta pos/rot to teleport, something like this:

    Code (CSharp):
    1. Vector3 camForward = camera.forward;
    2. camForward.y = 0f;
    3. Quaternion headRot = Quaternion.LookRotation(camForward);
    4. Quaternion deltaRot = RootMotion.QuaTools.FromToRotation(headRot, teleportTarget.rotation);
    5. character.rotation = deltaRot * character.rotation;
    6.  
    7. Vector3 camPos = camera.position;
    8. Vector3 deltaPos = teleportTarget.position - camPos;
    9. deltaPos += camPos - character.position;
    10. character.position += deltaPos;
    Best,
    Pärtel
     
  18. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hi Partel,

    Whenever I'm walking backwards with VRIK, I can see a bit of the inside of my head, because it seems the head of the character lags a bit behind to reach it's target.

    How can I fix that?

    Many thanks,
    Gabriel.
     
  19. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    326
    Is it possible to use Final to create procedural animations? Great asset btw
     
  20. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Ah sorry, I should have seen that. Thank you

    I've tried implementing this but I don't think that it is solving the issue for me. I have tried adding it to the upper arm, then the shoulder and the forearm. It is working when rotating the hand, however, when making hand circles it is still moving the upper-arm.
    I'd like to be able to do this movement
    ( Sorry timestamp didn't work it's at 23 seconds )
    without engaging the upper arm.
    The upper arm is going a bit haywire when rotating the wrist despite the thumb not passing the 90 degree rotation



    I am also going against your suggestions :p and implementing full-body physics with puppetmaster. It is working fine, however, I am trying to implement the foot/hip trackers for full body tracking according to this guide you have on the first page

    But I wasn't sure what you mean by the root of the character needs to be parented to the pelvis tracker. Should I just add my Tracker container into my VRIK model?




    Lastly, do you have a buymeacoffee link or something?
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Does disabling "Plant Feet" fix it? VRIK reaches it's targets 100% within a single solver update step, so I'm guessing the head might just not be in reach (with Plant Feet ground contact takes priority over the head). Could be also that with SteamVR you'll have to go to SteamVR_Settings and set Pose Update Mode to OnLateUpdate only. Otherwise it will update the HMD/controller positions once more after VRIK has solved and it will lag behind.

    Hey and thanks!

    Yes, I mean there are easier ways to author animation (external 3D apps or UMotion Pro), but can be done procedurally with Final IK too if you want to drive it by script for example. Add the FullBodyBipedIK component, assign some gameobjects as head and hand and body targets and then you'll be able to move them from code. Make sure you move/rotate the root of the avatar along when you walk away from the initial spot though.

    Hey,

    So you need to keep the arm completely still as you rotate the hand? That you can only do if you set Rotation Weight to 0 for the arm, rotate the hand bone to match hand target rotation after VRIK has solved (use ik.solver.OnPostUpdate delegate). Could also use a bend goal to fix the elbow, but you'd have to make some kind of a script to drive the bend goal's position as you move the hand.

    About hip/foot trackers, have you already checked out the "VRIK (Calibration)" demo?

    Your purchase of PM and FIK bought me plenty of coffee already, thanks! :)

    Cheers,
    Pärtel
     
  22. DobriyGoodwin

    DobriyGoodwin

    Joined:
    Feb 2, 2021
    Posts:
    3
    Can someone direct me to information how set up my character's ability to walk with VRIK? I am new in game development and all scripts from tutorials I saw does not work with VRIK.
     
  23. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    I checked out the VRIK Calibration demo, I wasn't sure how to get it working with how the SteamVR+VRIK tutorial set things up.

    I ended up creating a tracking element with Hips, LeftFoot, Rightfoot with Steam VR_Tracked_Object and target spheres as children to each of them.
    I also duplicated the model root as a parent to hip.
    upload_2021-3-11_0-47-10.png

    The calibration now works too and the top half of the body+hips are working properly and are adjusted, but the feet are really messed up. The right foot is controlling the rotation of the entire body, and neither are adjusting properly. Also, the models toes are being detached from the body. Is this because the humanoid Mixamo model is incompatable? Or am I doing something wrong?

     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Something weird is definitely going on there, but couldn't spot it right away. Are the "lf target" and "rf target" assigned to the Target slots in VRIK leg settings? The feet should really match their positions if they were. If you could send me a repro or a unitypackage with your IK setup, I'd take a look here.

    Hey,
    If you have Locomotion weight set to 1 in VRIK settings, then it will "walk" with the procedural locomotion module. It was designed for just shuffling the feet around a few square meters space though, not good for thumbstick locomotion from A to B. If you need that, I'd suggest going for animated locomotion. Basically make a 8-dir strafing animation blend tree and make it follow the horizontal direction from the root towards the camera with root motion. Here's an example package to get started with that.

    Best,
    Pärtel
     
  25. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    326
    I was able to setup the animations for my character to an acceptable level with the AimPoser system. I was wondering how I would be able to create a shooting animation alongside this system? The AimPoser's script component doesn't have any example code inside it.

    From what I understand, you can add and modify more poses based on the axis of the lookat object. However, there isn't any option to setup a bool system.

    Here's what I'm trying to do:

    -The player presses the shoot button and isShooting is set to true. The animator then switches to animation of the shooting layer(Layer 2) to Recoil/Kickback/Shoot animation. So in simple terms AimForward>AimForwardShoot. Would this be possible using the AimPoser or should is there a workaround for this?
    I am using the AimPoser and lookAtIK in conjunction just like what is setup in the demo.
     
  26. DobriyGoodwin

    DobriyGoodwin

    Joined:
    Feb 2, 2021
    Posts:
    3
    Thank you, mate! I respect very much, for still supporting this thing and responding after all this time!
    If there are some mistakes in my sentence, sorry, english is my second language.
     
  27. DobriyGoodwin

    DobriyGoodwin

    Joined:
    Feb 2, 2021
    Posts:
    3
    Hey I checked out this locomotion package, but problem still stays, after character moves forward his lower body is following after head, maybe I am missing one of characteristics, but I still can not make character walk not like a drunk. I figured that it either walks weird or does not crouch, because the only way to reduce the speed difference between head and bottom part is reduce position weight of vr ik
     
    Last edited: Mar 15, 2021
  28. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    91
    Hi Partel,
    Is there a way to specify bend goal within interaction system? Or is the only way to specify it directly.
    Thanks
    David
     
  29. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Sorry, this was because my left foot goal in VRIK got set as right foot automatically somehow. It took me two days and messaging a friend to figure it out. o_O


    I got the full-body tracking to work but there are a few issues.

    I tried getting the calibration working, but it is incorrectly rotating the hands, making the legs too long, and pushing the hips forward oddly for some reason. Is additional development needed on the VRIK calibration script for it to work? Or am I doing something wrong? The model starts off hunched over since it was adjusted to my height and my friend wearing the gear is a lot shorter than I am


    Also, when walking around there is a lot of jitter. Is this because of collisions? I removed Puppetmaster for the time being since we are trying to do motion capture, but there was still a lot of it happening ( similarly to the video with the feet issue )
    my friend couldnt stop dancing, but here we can see the shoulders and chest jittering constantly. The foot issue seen here is already resolved
     
    Last edited: Mar 16, 2021
  30. studiopoof

    studiopoof

    Joined:
    Feb 22, 2020
    Posts:
    12
    I got a "syntax error," when I tried adding this script to my Unity project. Could somebody help me fix it?

     
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    If you add this script to the character:

    Code (CSharp):
    1. public class AimAdditive : MonoBehaviour {
    2.  
    3.         public AimIK ik;
    4.         [Tooltip("The direction of the animated weapon aiming in character space. Tweak this value to adjust the aiming.")] public Vector3 animatedAimDirection = Vector3.forward;
    5.  
    6.         void LateUpdate () {
    7.             ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedAimDirection);
    8.         }
    9.     }
    it will switch AimIK to additive mode, then you can play all your recoil, reloading, equipping, etc animations without AimIK constantly forcing the gun at the target. Will have to adjust the Vector3 value, that represents the animated aiming direction when aiming left or right or backwards. So when aiming left, slerp it from (0, 0, 1) to (-1, 0, 0).

    Hey,
    If you're OK with some foot skating, can force the character position closer to the horizontal position of the camera by script. Use the velocity of the camera too. It takes a lot of tweaking and experimenting to get it right, also depends on the animations you use, which is why I don't have a better solution for everybody.

    Hey,
    There's something very wrong with the setup there, but can't figure it out based on those videos. Any way I could get some kind of a repro so I could take a closer look here?
    The legs bending backwards is probably because of the model's initial pose though. Will have to rotate the knee bones in Editor a bit so the legs would be slightly bent in their natural bending direction.

    Hey,
    Can you share the error message from the Console please?

    Best,
    Pärtel
     
  32. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Yes, I can send a zip through email? Or is there any better ways to send it to you?
     
  33. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    91
    Hi Partel,

    In Offset Effector demo, the Offset Effector is use to control the Spline and Pelvis position. My question what is the "neutral" position of these effectors? That is where should I place them so they don't effect the animation (assuming I want to leave them enabled with weight of 1). From the demo it seems the corresponds to the neck position and first non-pelvis spline position. Can you confirm?

    Thanks
     
  34. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Probably too big for email. Dropbox or Google Drive it maybe and send a link to that to support@root-motion.com or PM here.

    Hey,
    Grab this little update please. Will be able to assign an "Anchor" transform to the OffsetEffector then. Use the bone that is closest to the offset effector. Then you'll be able to call offsetEffector.Anchor() in LateUpdate to match it to animation as close as possible.

    Best,
    Pärtel
     
    cybie likes this.
  35. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    77
    Hello Partel,

    I am having issues regarding VRIK. I have a full body tracked vrik character through htc vive and 3 trackers (for the pelvis and the feet). I control movement through my thumbstick and believe I am handling it correctly. When I move I change the positionWeight and rotationWeight to 0 for the pelvis and the feet, as well as change locomotionWeight to 0. When I am not moving with the thumbstick I change all the previous values to 1. I am seeing the blend animation that I set up for my feet play when I move and I am able to control my feet via the trackers when I am not moving, so I know that part at least is working. My issue is my characters body falls behind my camera rig when I move. I am moving through the default character controller. Please advise

    Also I would like to know if there are other best practices I should be aware of when doing full body VRIK. Thanks
     
  36. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    91
    Hi Partel,

    Is there a way to specify the bend goal while using interaction system?

    Thanks.
     
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    So the thumbstick locomotion is done with locomotion animations? and the avatar moves with root motion from the animation? Have you tried using the velocity of the camera? I mean do not make the animation just play catch-up with the camera, use the velocity to predict it ahead of time:

    Vector3 cameraV = (camera.position - lastCameraPosition) / Time.deltaTime;
    smoothCameraV = Vector3.SmoothDamp(smoothCameraV, cameraV, ref v, velocitySmoothingTime); // smoothing gives better stability
    lastCameraPosition = cameraPosition;

    Add some of that smoothed velocity vector to the locomotion target.

     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Yes, the InteractionObjects have "Bend Goal Weight" curve types, that you can use.
     
  39. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    77
    Hello, thanks for your previous tips. Having another issue regarding height when using VRIK and UMA. I am shorter than my UMA but would like to adjust my camera height rather than adjust the character height (I would like for all my players to play the same size character). I have tried using VRIKAvatarScaleCalibrationSteamVR.cs but I cant tell if its adjusting the heighr (my character has a hunchback that doesnt go away). Is there another way to fix this?

    SOLVED
    Note: I changed the above script to
    float sizeF = (ik.references.head.position.y - ik.references.root.position.y) / (ik.solver.spine.headTarget.position.y - ik.references.root.position.y);
    xrContainer.transform.localScale *= sizeF * scaleMlp;

    this rescaled the xr rig to better fit the avatar, the original script scaled the avatar to match the xr rig (other way around)
     
    Last edited: Mar 22, 2021
  40. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    326
    I'm running into an issue where aimIK is "killing" my shooting animation. I want to keep the spine rotation but want the arms to run the animation. It seems like it's still controlling the all of the upper body during the animation. Is there a fix for this?

    upload_2021-3-26_0-7-54.png
    upload_2021-3-26_0-8-11.png
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Check out the "Aim Controller" demo. AimController is a helper tool for AimIK that takes care of all the smooth target switching, direction interpolation, root rotation and other things. Enable "Use Animated Aim Direction", that will put AimIK in additive offset mode and allow you to use all your recoil, reload and equipping animation. If the aiming becomes inaccurate, that means the character is not aiming exactly forward in the animation and you'll have to tweak the value of "Animated Aim Direction" to fix it.

    If you don't want to use AimController, you can use this little snippet instead:

    Code (CSharp):
    1. public AimIK ik;
    2.         [Tooltip("The direction in which the weapon is aimed in animation (in character space). Tweak this value to adjust the aiming.")] public Vector3 animatedAimDirection = Vector3.forward;
    3.  
    4.         void LateUpdate () {
    5.             ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedAimDirection);
    6.         }
    Best,
    Pärtel
     
  42. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    326
    Amazing! Literally fixed my problem within a minute. Thank you so much.

    From what I get from the AimController script, I would have to create my own aim offsets correct? It does work but sometimes is off for other angles.
     
    Last edited: Mar 28, 2021
  43. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    The aim offsets represent the aiming direction in the animation. So if in your animation the gun is aimed exactly forward, the aiming will be correct with (0, 0, 1). So if you switch to aiming right animation, you'll have to slerp animated aim direction to (1, 0, 0).

    Best,
    Pärtel
     
    billygamesinc likes this.
  44. acallerame

    acallerame

    Joined:
    Apr 14, 2017
    Posts:
    2
    Hey Partel! I'm working with a multi-link robot arm and I'm using the CCD IK to solve for the motion. However, part of its function is for the target to loop around a gear and collide with another part of the arm, causing the arm to move further in its preferred direction. However, when I apply colliders to the objects that are supposed to collide with each other(link 3 and the target), the robot will shake a little and the colliders will just pass through each other without moving the arm in the correct way. I've tested the colliders to ensure they interact with other colliders on the robot, which they do. Is there something in the script for the IK which is preventing the colliders from working as intended?
     

    Attached Files:

  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    Final IK is inverse kinematics, not dynamics, so you can't use colliders in the solving process. You need a physics based solution for that. Please check out this package. I made a script that makes PhysX work sort of like an inverse dynamics solver.

    Best,
    Pärtel
     
  46. acallerame

    acallerame

    Joined:
    Apr 14, 2017
    Posts:
    2
    Thanks! I appreciate the info and the package! Ill give it a try now :)
    -Angelo
     
  47. unitydreamer29

    unitydreamer29

    Joined:
    Dec 27, 2020
    Posts:
    47
    Hi Partel!

    I am using VRIK with a blendtree for thumbstick locomotion, which works well. I bring the locomotion solver weight back up to 1 when the player is stationary so they can still shuffle around. When the player is not using the thumbstick, and physically walks around the VR tracking space, the legs/feet don't seem to track the body well and the body becomes stretched out, like it is laying down or in a superman pose. Do you have any tips on how to keep the feet under the body in this case?

    Thanks!
     
  48. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    Hi Partel,

    I am using the GrounderFBBIK component. I would like Spine Bending to work downhill as well as uphill, but as implemented it only works uphill. Through debugging I can see Grounder.GetLegSpineBendVector is returning approximately Vector3.Zero. Inside that method, depending on which leg is being checked, either the value of dotF or the value of w will be near zero. Could you please explain why this is, and maybe suggest what I could implement in order to achieve downhill spine bending? Thank you very much!
     
  49. sowatnow

    sowatnow

    Joined:
    Jun 12, 2014
    Posts:
    309
    Hi Partel,

    I am using GrounderBipedIK and occasionally getting this error and player right leg stretches backward.
    Don't know why this happens, but kind of game breaking bug.

    Code (CSharp):
    1. Assertion failed on expression: 'CompareApproximately(det, 1.0F, .005f)'
    2. UnityEngine.Quaternion:FromToRotation(Vector3, Vector3)
    3. RootMotion.FinalIK.GrounderBipedIK:OnSolverUpdate() (at Assets/RootMotion/FinalIK/Grounder/GrounderBipedIK.cs:128)  
    4. Line 128 code:                 Quaternion f = Quaternion.FromToRotation(up, up + spineOffset);
    5. RootMotion.FinalIK.IKSolver:Update() (at Assets/RootMotion/FinalIK/IK Solvers/IKSolver.cs:42)
    6. Line 42: if (OnPreUpdate != null) OnPreUpdate();
    7. RootMotion.FinalIK.BipedIK:UpdateSolver() (at Assets/RootMotion/FinalIK/BipedIK/BipedIK.cs:275)
    8. Line 275:             if (solvers.spine.bones.Length > 1) solvers.spine.Update();
    9. RootMotion.FinalIK.SolverManager:LateUpdate() (at Assets/RootMotion/FinalIK/IK Solvers/SolverManager.cs:108)
    10. Line 108:             if (timeStep == 0) UpdateSolver();
    11.  
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,554
    Hey,
    You have to call ik.solver.Reset() before you start bringing locomotion weight back to 1. That will make the footsteps catch up with the avatar.

    Code (CSharp):
    1. // Gets the bend direction for a foot
    2.         private Vector3 GetLegSpineBendVector(Grounding.Leg leg) {
    3.             Vector3 spineTangent = GetLegSpineTangent(leg);
    4.             float dotF = (Vector3.Dot(solver.root.forward, spineTangent.normalized) + 1) * 0.5f; // Default behaviour, not bending spine when going downhill
    5.             //float dotF = Mathf.Abs(Vector3.Dot(solver.root.forward, spineTangent.normalized)); // Bending spine backwards when going downhill
    6.             //float dotF = Vector3.Dot(solver.root.forward, spineTangent.normalized); // Bending spine forward when going downhill
    7.             float w = (leg.IKPosition - leg.transform.position).magnitude;
    8.             return spineTangent * w * dotF;
    9.         }
    Hey,
    Have not seen that error before. Could you please add this:

    Code (CSharp):
    1. Debug.Log("up: " + up + ", spineOffset: " + spineOffset + ", spineOffsetTarget: " + spineOffsetTarget);
    right above the line that produces the error. When the error happens, pause the game and let me know what it logged just before the red error message.

    Best,
    Pärtel