Small lib for creating ragdolls

Hi everyone. I made a small javascript class to help with the creation of ragdolls. Here it is on github.

I made some examples on the playground:

In theory it works with AmmoJS, CannonJS and OimoJS… however, I only got it to work relatively well with OimoJS, mainly due to the joint limits that are available on some of the OimoJS joints.

I made this for a personal project I’m currently working on, and then decided to open source it. Hope it helps someone out. Any feedback is much appreciated.

19 Likes

This is super cool! Thanks a lot

1 Like

I am looking for similar feature, thank you very much! :smiley:

1 Like

I just wanted to bring this super idea back to the surface.

The Figure’s joints shouldn’t be able to rotate in all directions, so it looks unrealistic.

1 Like

Hello Necips! We can totally choose rotation directions with this lib. If the bone is rotating in a way that seems unrealistic, we can choose other rotation axes. In the examples I posted above, this is the ‘rotationAxis’ property in the config. We can also define rotation limits, with the ‘min’ and ‘max’ properties. But yes, the examples I gave could be more realistic (they were made in a hurry :cry:).

Now, rotation limits aren’t available for all the joints, and as far as I know, they’re only currently available if we choose OimoJS as a physics engine. However, I believe we can achieve something similar to rotation limits using other physics engines and/or joints. It’s probably gonna be a little bit tricky… but there are some tricks I believe could work, such as:

  1. Having some sort of callback after each physics step (something like the afterStep we see in the PhysicsImpostor Class) and reseting the rotation values if they go above a certain limit. I actually tried this, but failed miserably. But only because I’m super lazy… but hey, if there’s anyone out who really needs this, I can try it again :grin:.
  2. Another idea would be using some kind of stopper meshes. Wingnut talks about this method in some posts, like this one.

Another super valid criticism of this lib would be: well, if we’re using hinge joints (as in the examples I posted), we can only rotate in 1 axis… and there are clearly joints in our body that rotate in more than 1 direction (e.g. shoulder joint and knee joint). What if we want a joint that rotates in multiple directions AND has rotation limits like I described above?? For this issue, there are also some possible solutions:

  1. We can choose another joint that supports rotation in multiple directions (e.g. ball and socket joint), and use the rotation limit method I described above (using the afterStep in the PhysicsImpostor Class and adjusting angles when needed).
  2. Another solution would be using 2 or 3 hinge joints between bones (instead of just the usual 1 joint), and make each hinge joint rotate in different directions. Hinge joints already allow rotation limits (with OimoJS), so we’re good.

Ranaan talked about the afterStep physics solution and the multiple joints between bones solutions in this post.

Thank you. I am glad that solutions are available.

As you demonstrated well it is not necessary to use a lot of imposters which slows down the flow of the game. Intelligently and purposefully used in a few places is enough to create a good feeling while playing.

A simple idea and so powerful in its effect! Great again.

1 Like

nice!

1 Like

Think that is a little better https://playground.babylonjs.com/#40AH5S#5 then Babylon.js Playground. :slightly_smiling_face:

1 Like

Looking good!! I thought having overlapping collider boxes would cause issues, but apparently not :stuck_out_tongue:

1 Like

May we should use bigger boxes?

killed in zero gravity on mission

kill’em first then drag his hand (the box of his hand)

1 Like

Buahahah that’s hilarious :joy:

@REX_DUNGEUR we most definitely can. I played around a little bit with the Vita model and added slightly bigger boxes (and some angle limits as well)

https://playground.babylonjs.com/#40AH5S#9

We can see that there is less intersection of arms/legs happening, which is nice. Also the mesh is less likely to go bellow the floor. Is it the best approach for all cases? I’m not sure :stuck_out_tongue:

1 Like

lol @Necips:joy:.Look at that:

Try to make a demo for a dummy crash test, Rex.

I’m working… :slightly_smiling_face:

Here @Necips: https://playground.babylonjs.com/#PVKQM1#3

1 Like

Or that: https://playground.babylonjs.com/#PVKQM1#4



Remembers me to a snapshot while throwing the oponent in Aikido! :blush: I will try to move his hand like a master would do…

Cool!