Skip to content

Instantly share code, notes, and snippets.

@innocuo
Last active February 25, 2022 07:32
Show Gist options
  • Save innocuo/f899ca5fd21beb962f72e1f9431802ee to your computer and use it in GitHub Desktop.
Save innocuo/f899ca5fd21beb962f72e1f9431802ee to your computer and use it in GitHub Desktop.
How to create a rigged humanoid character using Clayxels and Puppet3D.

This is not a tutorial, just an overview of my process to create a character with Clayxels that can be used with character controllers like the one in Game Creator or Ootii's Motion Controller.

Quick overview:

  • sculpt a character using Clayxels
  • freeze to a mesh, save it in your Assets folder
  • use that mesh to create a new GameObject
  • attach AddUV script to the new GameObject and switch to play mode to generate a mesh with a UV map
  • replace the mesh in this GameObject with the new mesh, remove AddUV script
  • use Puppet3D's autorig
  • export Skin and Bones
  • Set exported asset as a Humanoid

Why?

This is an exploration of how you can go from an idea to a working character without leaving Unity. You can use Clayxels to sculpt, Puppet3D to rig, and Game Creator to add movements and controls to your character.

What's needed:

Details:

1. Clayxels

  • Create a ClayxelsContainer and sculpt a humanoid character (something with a head, chest, two arms and two legs)
  • add a name in the "save asset" field, and click on "Freeze to mesh". This saves the mesh in the Assets folder.
  • Create a new material using the ClayxelBuiltInMeshShader shader (otherwise your new character won't keep the colors created on Clayxels)
  • We no longer need the clayxels gameObject. Hide it.

2. Process Mesh

  • create a new GameObject

  • add a MeshFilter component

  • add a MeshRenderer component

  • assign the mesh created in the previous step to the MeshFilter component

  • assign the material created in the previous step to the MeshRenderer component

  • you should now have a gameObject that looks just like what you created on clayxels

  • add the AddUV component to the gameObject (see source at the end of this gist)

  • switch to play mode, and back to edit mode

  • there should be a mesh called "character" in your assets folder

  • remove the AddUV component

  • replace the MeshFilter mesh with this new character mesh

3. Rig your character

  • open Puppet3D autoRig panel
  • Select your character gameObject, and click on "Make Guides" in Puppet3D
  • adjust guides to match your character
  • click on "AutoRig" on Puppet3D
  • more info: https://www.youtube.com/watch?v=xUbirkhY7Vo

4. Export your character

  • open Puppet3D's Skinning panel
  • select your character gameObject
  • make sure it now has a SkinnedMeshRenderer component instead of a MeshRenderer component (that means the autorig process worked)
  • Click on "Export Skin & Bones" on Puppet3D
  • see the message on Unity's console. It'll say where it saved the new asset
  • Find the new asset in the Project panel. Select it. In the inspector panel, select the "Rig" tab. Change animation tab to "Humanoid" and click on "Apply"
  • your asset is now ready to be used with a character controller.

Troubleshooting

Puppet3D doesn't export your mesh if the mesh doesn't have a uv map. That's the purpose of using the script. You can use a uv inspector to make sure your mesh has a uv map.

If the script doesn't work, you can export your mesh as an fbx with Unity's FBX exporter, import it in Blender, assign a UV map, export it from Blender and back into Unity.

Known issues:

  • Puppet3D doesn't export the material correctly, so when you use your new humanoid character, you also need to reapply its material with the one that uses the ClayxelBuiltInMeshShader shader
  • you are now using a normal mesh, so none of clayxel's features are available for this new character.

Tested with:

I tested this with Ootii's motion controller, Game Creator, and it can also be used with mixamo's animations (when you download a mixamo animation, you need to change it to a humanoid, the same way we did with the Puppet3D exported asset).

About the AddUV script

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class AddUV : MonoBehaviour
{
public Mesh mesh;
void Awake()
{
mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Vector2[] uvs = new Vector2[vertices.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(vertices[i].x, vertices[i].z);
}
mesh.uv = uvs;
AssetDatabase.CreateAsset(mesh, "Assets/character.mesh");
AssetDatabase.SaveAssets();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment