2013-08-31 30 views

回答

0

如果你的模型有一個電樞,你可以爲電樞元件製作動畫或者在你的建模程序中,然後通過腳本觸發這些動畫。

編輯:繼承人我發現通過腳本控制網格,你可以改變它以適應你的需求,我仍然認爲這將是更容易回到建模程序,並放入電樞,並再次出口它已經有一個armiture和動畫,這是我可以幫你的

using UnityEngine; 
using System.Collections; 

[ExecuteInEditMode] 

public class VertHandler : MonoBehaviour 
{ 
    Mesh mesh; 
    Vector3[] verts; 
    Vector3 vertPos; 
    GameObject[] handles; 

    void OnEnable() 
    { 
     mesh = GetComponent<MeshFilter>().mesh; 
     verts = mesh.vertices; 
     foreach(Vector3 vert in verts) 
     { 
     vertPos = transform.TransformPoint(vert); 
     GameObject handle = new GameObject("handle"); 
     handle.transform.position = vertPos; 
     handle.transform.parent = transform; 
     handle.tag = "handle"; 
     //handle.AddComponent<Gizmo_Sphere>(); 
     print(vertPos); 
     } 
    } 

    void OnDisable() 
    { 
     GameObject[] handles = GameObject.FindGameObjectsWithTag("handle"); 
     foreach(GameObject handle in handles) 
     { 
     DestroyImmediate(handle);  
     } 
    } 

    void Update() 
    { 
     handles = GameObject.FindGameObjectsWithTag ("handle"); 
     for(int i = 0; i < verts.Length; i++) 
     { 
     verts[i] = handles[i].transform.localPosition; 
     } 
     mesh.vertices = verts; 
     mesh.RecalculateBounds(); 
     mesh.RecalculateNormals(); 
    } 
} 
+0

感謝JRowan先生的回答。但我想編寫個別部分的腳本,而不是爲它製作動畫。通過零件移動,我想改變方向並旋轉飛機。如果你能提供這樣的腳本或指導,那將是善良的。謝謝... –

+0

我更新了一些代碼,我從來沒有嘗試過,我把動畫放在我所有的模型上,並在腳本中做動畫,它很容易,我從http://answers.unity3d.com/questions/獲得這個。 14567 /編輯 - 網格頂點合unity.html – JRowan

相關問題