Search Unity

Question How to add new skinned mesh render to a character?

Discussion in 'Editor & General Support' started by hiaron123, May 23, 2023.

  1. hiaron123

    hiaron123

    Joined:
    Jul 18, 2019
    Posts:
    28
    I've got a question which is skinned mesh renders object is tied to the bone so when it has some sort of animation, it still syncs well. What if the artist have created a character which I already create a lot of script and reference to it then there's a new cloth or item need to sync with the character? Do the artist create the new item in modelling software using the same bone and export the gameobject which i just drag into the character and it automatlly sync since it's the same bone?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    A ton of things happen at import time to hook it all up.

    Fortunately there is a simple scripting example that builds some geometry, bones it and attaches a SkinnedMeshRenderer.

    https://docs.unity3d.com/ScriptReference/Mesh-bindposes.html

    Boneheadedly this example produces geometry facing AWAY from the camera (sigh) so you need to either make the camera look -Z instead of +Z, or else flip the winding order. This line:

    Code (csharp):
    1. mesh.triangles = new int[] { 2, 3, 1, 2, 1, 0 };
    should probably be something like:

    Code (csharp):
    1. mesh.triangles = new int[] { 2, 1, 3, 2, 0, 1 };