Avatar SDK Local Compute Unity plugin  2.2.2
Toolset for Head 2.0 avatars generation in Unity3D
Scene #03: Fullbody Legacy Sample

This scene shows how an avatar (Head 2.0|head/mobile pipeline) can be easily attached to a fullbody character in runtime and animated with skeletal animations.

It is a legacy solution that doesn't give a seamless connection between the head and the body. We recommend you to use a Full Body pipeline that is available in the Avatar SDK Cloud Unity plugin: https://accounts.avatarsdk.com/developer/#unity-plugin.

In some versions of Unity the attached head might appear upside down. This happens because certain Unity builds break the bindpose 4x4 matrix during the plugin import. If this happens, please go to the male_suit->body_attachment_suit object in the scene, find BodyAttachment script component and press Rebuild Bindpose button on this component. Press Save and restart the scene. Please contact us if this does not fix the issue.

User interface and the scene

The user interface on the left allows you to manipulate the relative position of the head once it attached, in realtime. It is implemented via manipulation of the 4x4 bindpose matrix. Take a look at PositionControl.cs and ChangePosition method in BodyAttachment.cs to see the implementation details. If you run the sample in the Unity Editor, there is a possibility to create a prefab object. Just press the corresponding button in the bottom right corner.

The cartoon dummy character is added to the scene as a reference, to demonstrate how the idle animation is played back on its original model.

How do I attach a head to my own character?

From the developer point of view, this is how it's supposed to work for new characters:

  • You create your fullbody model in the 3rd party 3D software, let's say Blender. Then you remove the existing head and import the resulting headless model to Unity (just like it's done with the male_suit model in the sample)
    full_body_fbx.JPG
  • Place your fullbody model in Unity scene. Add a child empty gameObject to it and call it "BodyAttachment". Add the BodyAttachment.cs script component to it.
    add_body_attachment.JPG
  • As a child of BodyAttachment add a sample AvatarSDK head (you can save your own to the prefab or use the sample head from the folder itseez3d\avatar_sdk\samples_core\models\sample_heads\animated_face just like it's done in the sample
    add_head_to_body_attachment.JPG
  • By moving and rotating the head manually make sure that it fits just about okay. This will be the head position in the neutral pose.
    fit_head_manually.JPG
  • Go to the BodyAttachment script component and fill the public fields of the object: head transform, head and neck bones and you fullbody object (the one that contains the SkinnedMeshRenderer body component, again, just like in the sample). Leave Head Bind Pose and Neck Bind Pose fields unchanged for now.
    body_attachment_fields.JPG
  • Press the button Rebuild Bindpose. This is very important - this is where script calculates the correct 4x4 matrices that will attach the runtime-generated avatar head in the right place and to the right bones.
    rebuild_bindpose.JPG
  • When you generated the head at runtime, just call the function AttachHeadToBody and pass the head GameObject. Method DisplayHead of FullbodySample.cs demonstrates how to do this.

See also FAQ and the getting started instructions on the main page: Main Page.