Like sims character modifier script?

Hi! I try make character modifier script like sims have. I think best solution is this

  • Do 2 model of character (“non-fat” & “fat”) (Whit same count of vertex).

  • Place models in unity in same position.

  • Duplicate another model and put “non-fat” & “fat” models in dublicated model. (To children).

  • Calculate children models vertices positions difference.

  • Add difference to Parent model vertices position.

    public class VertexManipulation : MonoBehaviour {
    public GameObject Obj;
    public Mesh mesh = new Mesh[3];
    private Vector3 vertices1;
    private Vector3 vertices2;
    private Vector3 vertices3;

     public float SuperAwesome = 0.5f;
     // Use this for initialization
     void Start () {
     	mesh[0] = Obj[0].GetComponent<MeshFilter>().mesh;
     	mesh[1] = Obj[1].GetComponent<MeshFilter>().mesh;
     	mesh[2] = Obj[2].GetComponent<MeshFilter>().mesh;
     	vertices1 = new Vector3[mesh[0].vertexCount];
     	vertices2 = new Vector3[mesh[1].vertexCount];
     	vertices3 = new Vector3[mesh[2].vertexCount];
     	vertices1 = mesh[0].vertices;
     	vertices2 = mesh[1].vertices;
     	vertices3 = mesh[2].vertices;
     // Update is called once per frame
     void Update () {
     	Vector3[] Different = new Vector3[vertices1.Length];
     	for(int X = 0; X<Different.Length; X++){
     		Vector3 worldPt1 = Obj[0].transform.TransformPoint(vertices1[X]);
     		Vector3 worldPt2 = Obj[1].transform.TransformPoint(vertices2[X]);
     		if(worldPt1 != worldPt2){
     		Vector3 Heading = worldPt2 - worldPt1;
     		Heading = new Vector3(Heading.x * SuperAwesome,Heading.y * SuperAwesome,Heading.z * SuperAwesome);
     		Different[X] = worldPt1 + Heading;
     			Different[X] = worldPt1;
     	mesh[2].vertices = Different;


This script kindly work. Problem is when i get vertices in mesh, it dont give me correct vertices if mesh is little bit “harder”. I dont have this problem whit simple 2D meshes. Any solutions how i fix this?

Obj[0] = “non-fat”;
Obj[1] = “fat”;
Obj[2] = Mesh We Want To Modify;
SuperAwesome = How Much We Want To Change Obj[2].mesh.vertices positions from Obj[0].mesh.vertices positions to Obj[1].mesh.vertices positions;

I find the problem is hard edges :slight_smile: If models have same count of hard edges this works fine. The is something still what is cracking me. If i transform object somewhere out of (0,0,0), mesh will “move faster” than my object origin. is there something wrong whit “worldPt1” and “worldPt2”?