IK Collision by geometry nodes

I made an IK with referencing this video.

It’s working well when interact with 1 object.
Right now I am looking for other method to collide with multiple object like tight, hip, waist. Can raycast from collection to do something similar?
IK collision.blend (1.3 MB)

1 Like

I’m not totally sure what your nodes are doing-- I think it’s probably more complicated than it needs to be. Basically, you’re comparing the size of two spheres, right? And based on that comparison, you push one of the spheres out until it doesn’t intersect.

And, even though you’re doing this currently on the basis of object transforms, you could do it from the positions of various selections of geometry instead.

So the major problem with scaling this up to more colliders is you can have a situation where your collision body intersects with two different colliders, and pushing them out of one, pushes them directly into another.

Now, yes, you could use a different way of doing this, by checking nearest surface normal of an instanced collection and checking if you’re inside of it. But, it’s entirely possible that pushing yourself out of one collision pushes you into another collision. Or, that self-intersection in the collection means that you don’t detect that you’re inside one mesh, because you’re outside of another mesh that’s closer.

The best way to handle collision is always going to be physics. Rigid body physics are expressly designed to handle collision. There’s no need to reinvent physics inside of GN: the best you could ever get would be something that is just as good as what rigid body physics already deliver. (If you could get better, it’d just get implemented into the rigid body physics code. And the rigid body code is some stuff that’s been around for a long time, with a lot of smart people looking at it.)

4 Likes

My settings now are only apply to sphere, so I’m looking a way using raycast normal from any surface to push away my object B when object A is over the surface.
Something like this(sorry this video is from maya)

Since you mentioned rigid body, do you mean I can use animation from FK rig to control rigid body and then pass the collision result to IK rig?

Yes. Create two rigid bodies, one animated-type, parented to the base control (which can be anything, FK vs IK doesn’t really matter here); create a fixed-type rigid body constraint to connect the two. Set the collision type as desired. Copy transforms or child-of the IK bone to the un-animated rigid body. Create any kind of animated-type collider rigid bodies and parent them to other bones (or objects I guess) as desired.

Thanks, will try it out now. And share the result later.

Here is the result by using rigid body, looks good.
Next step will be how can I reduce the vibrate when two active rigid body touched?
rigid body.blend (1.0 MB)

The problem is that the constraint says, “be where I want you to be” but it can’t get there because you blocked it. The further the constraint goes, the more force it exerts trying to get there. The vibration is because there is randomness in the simulation to allow it to overcome unrealistic balances.

What I’d recommend first is using different primitive shapes for your collision bodies. If you use spheres and capsules, the bodies will slide over each other rather than get stuck. You’re best off shaping these via the collision settings in your physics settings, rather than via the mesh, because the collision primitives are mathematical and smooth-- a mesh sphere is faceted, no matter how many vertices you use, but a rigid body sphere is an actual smooth sphere. You can consider setting friction values to 0 as well so that they slide over each other well. IIRC friction is an additive property, so you want it on the dynamic rigid bodies as well as the parented rigid body colliders.

Another thing you could do is use spring constraints instead of fixed constraints. These will allow the body to have some tolerance relative to its constraint. The risk here is then that you get inertia and gravity into play. If you do this, you should probably disable gravity in your scene and set your bodies’ translation and rotation damping to 0.

There’s one more thing I’d recommend, although at this point I’m not sure that it’s not just superstition. I always apply scale on all my rigid bodies. Unapplied scale used to create problems in simulations. I’m not sure that it still does.

1 Like

Thank you for sharing so much. I tried to use capsule in shape settings but both active rigid body just go through each other like nothings happened, even add scale to make it longer. So I tried cylinder and it works well in my scenario. The vibration still occur when the collision goes too deep, If any motion that applied to my character still makes rigid body vibrate like crazy, maybe the motion isn’t realistic at the beginning.

The problem you’re probably having with the capsule is that it demands a certain orientation from your objects.

The capsule, here, is just a sphere, even though the input shape is long in one axis.

But if we rotate the object axes, then the capsule matches the shape:

Although I have to show with wireframe here because the capsule is contained inside the box.

Sorry, I just can’t get the same shape you have.
1.I tried rotate the origins > scale in one axis > apply rigid body > capsule

2.Scale in one axis > apply rigid body > capsule > rotate origin

3.Scale in one axis > rotate origin > apply rigid body > capsule

It doesn’t look to me like you’ve applied scale on your object.

I scale at the transform without affect only origins check, am I doing it wrong?

Yes. Apply scale. With a scaled object selected, like the one you have, hit ctrl-a in the 3D viewport and select “scale”.

2 Likes