Make object stick to both hands of a character

Hi

tl;dr:

  • increase bone limit in BoneIKController?
  • chain together BoneIKControllers?
  • any other ideas?

I am stuck. Not the hands of my character though. Progress so far: You can stick any mesh to a bone. This works great for one hand.

However, say, you have a machine gun. You attach its grip to the character. But now he is holding a machine gun with one hand only? Aiming will probably be difficult.

How do you get the other hand on the foregrip and make it stay there? I had little success with the BoneIKController. The limit of 2 bones is too constraining here. You need at least lower arm and upper arm be driven by the hand. Ok, I though maybe I can chain together multiple BoneIKControllers? I could not get this to work.

Can you chain together BoneIKControllers?

Or even better: can you increase the number of bones the BoneIKController controlls?

Or is there any other way I could stick the second hand to the same object the first hand is holding?

Best wishes
Joe

Can you share your current progress with two controllers ? One on each hand should be fine I guess but hard to understand the problem without a repro.

I would advise to create an animation offline for this :slight_smile: as it will also save perf.

@PatrickRyan might have an idea ?

@Joe_Kerr, we would love to expand the BoneIKController to handle more than two bones. This obviously isn’t enough in most cases, and there is interest in expanding this solution on our team. We just haven’t been able to fund it yet. I don’t think chaining them would be a great solution and that would cost extra perf for a solution that may be a little wonky.

But I agree with @sebavan in that you will get more performance if you were to can the animations you need for your off-hand if your UX allows for it. If your character has canned animations for all their actions and you are not doing something real time like the character’s hands are holding an attachment in XR first person driving the attachment by the controller’s orientation, then animation would far cheaper at runtime.

In setting up your character in your digital content creation (DCC) tool, you can set up the off-hand on an IK solver and then animate it with the main hand through your rig constraints. If you need to switch the position of the off-hand based on the attachment used, you could simply transfer in a new set of animations with the off-hand in the correct position based on the attachment. Some attachments would likely require new animations anyway so this would be no more overhead. If you just need to move the off-hand position and not change animation - i.e. one attachment is shorter than another - you could use an additive animation to blend your offset animation with the main animation. This will move your off-hand to the correct position, but retain the rest of the animation.

If none of these suggestions work for your pipeline, you could always expand BoneIKController to handle more bones and contribute it back to the engine. If you decide this is the path, then I would suggest talking with @RaananW about your plans. Hope these suggestions are helpful.

3 Likes

Thanks guys for your input.

I do like to have options. And going the “animations route” sounds like a good way forward. Also, speaking for Blender, generating these corrective animations should be possible using scripting only. Sweet.

However, having spent some time with all this IK stuff: now I want to have it :blush: Because the possibilities! In fact, I have been checking out existing solutions like this one. If I get it to work, I will post it here.

1 Like

hey, I have been thinking about this recently too. I actually just want to implement grip ik for various common weapon types. Gripping arbitrary items is a pretty hard thing to solve, but I think preconfigured shapes should be very doable. What i am using right now as a use case is this sketchfab model.

image

I’ve considered your problem as well, and i think it is pretty doable. I think the main thing to consider is, what bones do common models such as mixamo, ue, rpm, vrm/vroid, etc have. I also looked at how ue and omniverse create do retargeting, they both just have you map, at a minimum 5 joints, i think its head elbows and knees. However, the more you add, the better the retarget outcome will be.

I did some googling for human constraints and found a bunch of good stuff.

https://www.google.com/search?q=human%20joint%20constraints&tbm=isch&tbs=rimg:CZjFC8-w_1eZlYVCw4ES6913R8AEAsgIMCgIIABAAOgQIARAA&bih=961&biw=1920&rlz=1C1RXQR_enUS1004US1004&hl=en&sa=X&ved=0CAIQrnZqFwoTCMCshbOA8_oCFQAAAAAdAAAAABAI

Various tables similar to the one found here:
https://www.wikem.org/wiki/Range_of_motion_by_joint

Range of Motion Chart

Joint/Segment Movement Degrees
Elbow Flexion 140
Hyperextension 0
Forearm Pronation 80
Supination 80
Wrist Extension (Dorsiflexion) 60
Flexion (Palmar flexion) 60
Radial Deviation 20
Ulnar Deviation 30
Shoulder Flexion 180
Hyperextension 50
Abduction 180
Adduction 50
Shoulder with Abducted Arm Internal Rotation 90
External Rotation 90
Horizontal Adduction -
Horizontal Adduction -
Hip Flexion 100
Hyperextension 30
Abduction 40
Adduction 20
Extended Hip Internal Rotation 40
External Rotation 50
Knee Flexion 150
Ankle Plantar flexion 20
Dorsiflexion 30
Cervical Spine Flexion 60
Hyperextension 75
Lateral Flexion 45
Rotation 80
Lumbar-thoracic Spine Flexion 45-50
Hyperextension 25
Lateral Flexion 25
Rotation 30

I think codifying this information into ball/socket constraints would totally solve your problem

image

this has some good stuff that is helpful, like a ccdik solver.
.webxr-ik-avatar/implementation/src at main · danielshervheim/webxr-ik-avatar · GitHub

In addition to the generic ik lib you linked, these two are great also.
.GitHub - gkjohnson/closed-chain-ik-js: A generalized inverse kinematics solver that supports closed chains for parallel kinematics systems, dynamic reconfiguration, and arbitrary joint configuration based on damped least squares error minimization techniques
.GitHub - lo-th/fullik: javascript fast iterative solver for Inverse Kinematics

Also… we have Bullet physics at our disposal. I could continue on for pages, but i’ll stop here for now lol.

2 Likes

Hey, @jeremy-coleman thanks for the thoughts.

To give you a quick heads up what happened since my last post: I implemented this one and got it working under perfect conditions. There are a few issues I have to sort out but for a simple model it is looking very good! I will try to keep the actual solver interchangble.

Also, the human-constraints-idea is awesome. Shouldnt this in principle eliminate the need for these pole target shenanigans?

When you say “grip IK” do you mean that the fingeres should perfectly fit around the axe handle?

The human constraint tables should make the animations realistic and keep the arms from moving in really strange non-human ways. I dont think it would replace the weapon as a pole target, as that should kind of be the leaf “palm to weapon” parameter, i don’t think there’s any way around that. But, i think people do use pole targets to kind of dictate which direction stuff moves instead of hard coded constraints, and in that case, it would replace pole targets, being both faster and more realistic.

For the grip stuff, yes just grip the pole/gun/whatever. Either through IK without an animation defined or another option could be to have a premade hand skeleton and just replace the hands on every humanoid character. Babylon actually already has some stuff in the engine used for xr (although it seems like it could be useful elsewhere) and a hand skeleton on the github cdn.