All Classes Namespaces Functions Variables Enumerations Properties Pages
PuppetMaster Setup

To set up a character with ragdoll components as a Puppet, the easiest way is to simply add the PuppetMaster component to it and click on the "Set Up PuppetMaster" button. That will make a duplicate of the character and set the duplicate up as the Puppet while the selected instance will become the Target. Both will be parented to a new GameObject that is the root container for the entire character rig. A GameObject with the character's name + " Behaviours" will also be added. All Puppet Behaviours (BehaviourPuppet, BehaviourFall...) should be parented to it.

Alternately you can assign another character hierarchy to become the Target. PuppetMaster supports sharing ragdolls between multiple characters as long as the positions of the muscles match with their targets. Rotations can be different, so you can even use another rig with different bone orientations.

"Character Controller Layer" and "Ragdoll Layer" will be applied to the Target and Puppet respectively to avoid collisions between the character controller and the ragdoll colliders. Make sure collisions between the two layers are disabled in the Edit/Project Settings/Physics/Layer Collision Matrix.

PuppetMasterSetup.png


Creating puppets in run-time

The procedure and code for setting up puppets in run-time is demonstrated in the "Creating Puppets In Runtime" demo scene and CreatePuppetInRuntime.cs script. It requires for the character to be already set up with ragdoll components.

Transform ragdoll = GameObject.Instantiate(ragdollPrefab, transform.position, transform.rotation) as Transform;
ragdoll.name = instanceName;
// This will duplicate the "ragdoll" instance, remove the ragdoll components from the original and use it as the animated target, setting the duplicate up as a puppet.
PuppetMaster.SetUp(ragdoll, characterControllerLayer, ragdollLayer);
// or...
//PuppetMaster.SetUp(target, ragdoll, characterControllerLayer, ragdollLayer);
// or if you want the "ragdoll" instance to become the puppet, not the target:
//PuppetMaster.SetUpTo(target, characterControllerLayer, ragdollLayer);
Debug.Log("A ragdoll was successfully converted to a Puppet.");