Lerp, Slerp, Drives, Rigidbodies and punches to the face!

I’m working on a project that is beginning to get the better of me.

I’ve worked a lot with regular rigidbodies and force/torque application to achieve position/rotation targets but now I am trying to use joints and I feel like I’ve just dived head first into a very deep pool.

THE SETUP
I have created a humanoid out of primitives in Unity, created relevant configurable joints and given him a terrain to interact with, so effectively he is a ragdoll at the moment.
The ragdoll has then been dropped into an empty game object so that all of his local rotations = 0.
This empty game object contains a script with a var : GameObject to reference each primitive that has a joint attached.

THE DESIRED RESULT
I want this script to pick up keyboard input, each key bound to a series of ‘targets’ for the joints of the ragdoll to move to.
The script gets the key input(done), works out where the ragdoll’s joints need to move(done), sends the target variables to the relative joints(done), then those joints have a script attached to their gameobject that instructs them to move towards the required positions(this is what is stumping me).

From what I understand so far it should all be working correctly, I have ‘slerp drive’ set to velocity, all the rotational axis’ set to free movement and the maximum force set quite high. The issue is that when I change the target rotation for the joint, it doesn’t move.

I’ve been over and over this for 2 days now, reading the configurable joint documentation and scouring the forums and playtesting with all different settings but I simply cannot get the joints to do what I want. Once or twice they have randomly twitched but I don’t hold out any hope that I can learn anything from those anomalies.

I can gather screenshots or any other information required to overcome this issue and gain an understanding of how to get configurable joints to move to predefined target rotations with the press of a key.

PS. Hello Jean Fabre!

Im pretty sure that the physx implementation thats in unity, by defulat it wont work the way you want.
You’ve probably get it right, try turning off gravity on all the rigidbodies, and youll see that the joints ARE rotating, the problem is the physics just cant handle what you are trying to do.

A LITTLE MORE INFORMATION

The end goal is a fighting game whereby the characters animations are entirely driven by joint forces, allowing for realistic interaction.

I understand this is a huge goal and could be quite difficult, but after seeing Toribash and 3D Online Boxing, I am convinced it can be done.

I’ve created a script already to make setting up the movements easy. I position the character at the end point of the move in Unity then run the script. On the script beginning it prints all of the joints positions to a txt file, ready to be copied and pasted into a script to create that movement and bind it to a key press.

The way I was thinking of setting up input was - create script for each movement that simply holds the desired rotation of each joint, reference the movements script in the ragdolls parent object script, so the ragdoll will always try to move towards his default position unless a key is held down that corresponds to a movement script, in which case he will try to move that.

For example, if the “P” key is bound to a punching position, the player could press and hold the P key and the character will move to the punch position, effectively throwing a punch. On release of the key the character would retract the punch by moving back to default position.

Did I mention that I feel like I am in over my head??? :slight_smile:

I did turn gravity off and still no response from the joints. Kinematic does not work either.

Im fairly confident that toribash and sumotori dreams have an entirely custom physics implementaion, and not just using some plugin like Physx (as Unity does)

Here’s as far as I got when I tried to a few years ago
https://dl.dropboxusercontent.com/u/157182894/Builds/Walk/WebPlayer/WebPlayer.html
Looks like i dont have the project files on this machine so I cant check how i got this far, but you can see its not nearly fluid or responsive enough (Though I was actually aiming for that, a la Dead Drunk)

I’ve made some progress over night. I have a character that, although a little shaky, will respond to commands.

I’ll record a video and post it up.

Video posted!

Hi,

So it’s sorted right? from the video it seems to perform now? the thing to look for is stiffening the joints ( less shaky), and for this you should look for two thing, increase the physics “solver iteration”, I go up to 40 sometimes. And lower the fixed time step value in the time setting.

it’s really about fiddling about here, so you’ll need to test and test again with different values, go crazy with extremal values to get a feel of the acceptable range and find the sweet spot by narrowing down the range that suits your scene.

Bye,

Jean