2016-06-06 1 views

답변

0

Random 클래스와 함께 Instantiate Method을 사용하면이 작업을 수행 할 수 있습니다. 예 :.이 예에서

public class InstantiateExample : MonoBehaviour 
    { 
     public GameObject prefab; 

     void Start() 
     { 
      for (int i = 0; i < 10; i++) 
       Instantiate(prefab, new Vector3(i * 2.0f, 0, 0), Quaternion.identity); 
     } 
    } 

, 우리는 X 축 (More) *

따라 일렬 조립식 개체의 10 개 카피를 인스턴스화 본

같은 임의 위치를 ​​지정할 수

var position = Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10)); 
    Instantiate(prefab, position, Quaternion.identity); 

프리 패브는 동전, 장애물, 적과 같은 대상입니다.

관련 문제