I'm trying to make a Ragdoll that can move each limb individually. However when I try testing this on the Ragdoll's right leg, I get this error.
error CS1061:'CharacterJoint' does not contain a definition for 'AddForce' and no accessible extension method 'AddForce' accepting a first argument of type 'CharacterJoint' could be found (are you missing a using directive or an assembly reference?)
I tried switching AddForce with SwingAxis which didn't change anything. I looked up the methods for Character Joint but couldn't find any that would make the leg bend at the joint.
public class rightLeg_movement : MonoBehaviour
{
public CharacterJoint cj;
public float forwardForce = 2000f;
void FixedUpdate()
{
if( Input.GetKey("m") )
{
cj.AddForce(forwardForce, 0, 0);
}
}
}
All of the tutorials I looked up use an animation instead. However I plan on implementing an ai to do basic tasks with the Ragdoll(like learning to picking itself up, or learning to walk).
CharacterJoints don't have support for driving the joints built-in. You would be better off usingConfigurableJoints instead. Once you configure the limits on the joints, you can useConfigurableJoint.angularXDriveto configure the maximum angular force it can apply and thenConfigurableJoint.targetAngularVelocityto configure the target angular velocity.Also, it's recommended to call
Inputmethods inUpdateinstead ofFixedUpdatewhere possible. From the documentation:Altogether, these changes might look like this for something like a knee joint that can only move around the local x axis:
The documentation for
ConfigurableJointis currently in very poor condition so apologies if something is off.