0 votes
asked in VRIK by (160 points)
edited by
Exactly where and when does the VRIK solver decide what direction knees bend in?

We're making an avatar system for a VR app, where users can assign different avatars. So we load them from disk and assign them to the user that selected them.

But somehow, it comes out differently the second time someone uses the same avatar compared to the first time. The first time, the knees consistently bend towards the front, like I would want. But for some avatars, the second time anyone uses it, the knees are very bow-legged.

So, where in the VRIK set up process and/or code, does it decide which direction knees bend in? This will help me track down what exactly is different the second time.

EDIT: A possible clue is that the locomotion position also seems to be offset the second time an avatar is assigned. Like, to help the locomotion catch up when you teleport, we have a VRIKPlatform which teleports with you. Again, the first time you assign an avatar is fine, but the second time you assign an avatar, moving the VRIKPlatform to the user's location results in the locomotion being moved past that exactly as far, so the locomotion isn't at 0,0 anymore. (Calling vrik.Reset() does not address this)

1 Answer

0 votes
answered by (8.5k points)

Hey,

VRIK samples the pose when it initiates in Start(). For the legs it's in IKSolverVRLeg.cs, protected override void OnRead(), these lines:

bendNormal = Vector3.Cross(calfPos - thighPos, footPos - calfPos);

bendNormalRelToPelvis = Quaternion.Inverse(rootRotation) * bendNormal;

bendNormalRelToTarget = Quaternion.Inverse(IKRotation) * bendNormal;

It might be best to add VRIK after you load the avatar, not replacing references in VRIK.

VRIK ik = gameObject.AddComponent<VRIK>();

ik.AutoDetectReferences();

commented by (160 points)
Okay, I found something was slightly changing the position of the T-Pose. I've been able to force it back into the correct T-Pose by calling Update on the Animator before assigning the VRIK.

The locomotion position is still doing something weird, maybe I'll start another thread on that.

Welcome to RootMotion Q&A, where you can ask questions and receive answers from the developer of Final IK and PuppetMaster and other members of the community.

Post as a guest, create an account or login via Facebook.

Please use the correct category when you post your questions.

...