Inverse Kinematics for tenatcle

Dear Forum,

I am trying to build a series of creatures with Tentacles that move, and their force will propel my creatures. I need either forward or inverse kinematics for this, not sure which, I am thinking it is forward as the main “muscles” of the creatures are closer to their body. I have not been able to find any code on the forum that points to a usable IK solver, that has been translated.

My tentacles have 20 bones each.

Has anyone on here translated the code of something like fik.js to PC yet?

Can anyone point me to an example that has been built in here?

@will is there anywhere I can find this in your examples?

This mathematics is definitely over my head, and sadly I am the only programmer working in this at my firm, so I can’t bounce ideas off anyone else here.

Any help would be greatly appreaciated.



Hm… Could you fake it with joints? (see example here where you can drag the doll from any single limb:

1 Like

How do you achieve it with joints in playcanvas?

With not a lot of fun. Joints are not exposed in PlayCanvas but are part of ammo.js and therefore accessible. Will’s ragdoll project is the best example I know of that shows how it can be used.

1 Like

@yaustar I looked at that actually. Unfortunately there is little to no commenting in the code so I am having to guess at what he is doing, rather than being able to understand his thinking. I was hoping to implement what he is doing and translate it to deforming the skinInstance bones.

With all the wonderful features that PC has, I am surprised that they don’t have Kinematics built in, in such a way that it can be applied to bones.

I looked at implementing IK a long time ago, but it turned out to be too huge a task, we dont even have proper physics let alone something like IK

The bullet documentation (ammo is a JS compiled port of the bullet physics engine) is not great on the details for joints either. It took me a week to figure out the settings to get right for the ragdoll in Virtual Voodoo.

However, Will’s code will make more sense after reading the documentation and example code from bullet.

Re skinning: I was thinking you might be able to update the bone transformations every frame from the physics rigidbody.

Edit: actually, I need to take another look at the ragdoll, I vaguely remember it being skinned as well.

What do you mean by this?

still have the issue where the physics is not on a separate worker right? so it becomes slow, especially when there is a lot of stuff to render and also rigidbody sometimes falls through certain polygons

Physics is still single threaded which is unfortunately common in web physics engines. At the moment, most web games avoid using full on physics simulation libraries and rely on collision detection (ie no forces, resolving etc) which is much faster.

As for rigid bodies travelling through each other, I have only seen this on fast moving and/or small objects and can be mitigated by enabling CCD.

Not to step on any toes here…
yaustar is usually ontop of everything…superhuman, that guy!

But, I’ve been following some pretty cool projects and plug-ins from this guy:

Maybe hit him up and see if one of his PlayCanvas plug-ins can help or maybe he has some experience/advice.

1 Like

Looks like Will does do this for the ragdoll (updating bones position and rotation from the physics rigidbodies).

Adding a solver to do IK in 3D is quite a thing, most WebGL game engines still don’t provide a full blown solution, as of now.

Doing 2-bones IK for placing the feet of a character though is simpler.

I think, not sure though, that @Glenn_Ko did some research on the subject:

I have forward kinematics working for my tentacle. Was hoping to add some Perlin Noise for more randomized movement. Is that available in PC?