2013-01-10 70 views

回答

1

我會創建該路上的單個360°部分HelixPart Blender或任何您最喜愛的建模工具。然後將其導入Unity。

創建一個空GameObject並附上我們稱之爲HelixRoadCreator組件:

public class HelixRoadCreator : MonoBehaviour { 
    public int noOfParts = 5; 
    public GameObject helixPartPrefab; 
    void Start() 
     Vector3 newPosition = transform.position; 
     for (int i = 1; i <= noOfParts; i++) { 
      GameObject part = Instantiate (helixPartPrefab, newPosition, transform.rotation) as GameObject; 
      part.tranform.parent = this.gameObject.transform; 
      // recalculate newPosition, something like: newPosition += i* heightOfPart 
     } 
    } 
} 

現在拖動進口HelixParthelixPartPrefabHelixRoadCreator和調整noOfParts到你想要的號碼。找出正確的身高計算參數等等。

+0

我試過你的代碼,它給平均誤差說:在當前上下文中找不到變換? – Mohammed

+0

part.tranform.parent = this.gameObject;給我不能隱式地將'UnityEngine.GameObject'類型轉換爲'UnityEngine.Transform' – Mohammed

+0

@Mohammed不要忘記在行尾有'作爲GameObject'。當然有一個錯誤,應該說** this.gameObject.transform ** – Kay