LoginSignup
1
2

More than 5 years have passed since last update.

Unityオブジェクト複製基本

Last updated at Posted at 2015-06-13

複製1

public void Duplicate(){
    GameObject orgObj = GameObject.CreatePrimitive (PrimitiveType.Capsule);

    for (int i = 0; i < 50; i++) {
        float x = Random.Range(-3, 3);
        float y = Random.Range(-3, 3);
        float z = Random.Range(-3, 3);
        int rotX = Random.Range(0, 360);
        int rotY = Random.Range(0, 360);
        int rotZ = Random.Range(0, 360);
        Object.Instantiate(orgObj, new Vector3(x, y, z), Quaternion.Euler(rotX, rotY, rotZ));
    }
}

複製2

これはまだ編集中


    public GameObject[] RockPre;
    float time;

    void Start () {

    }

    void Update () {
        time+=Time.deltaTime;

        if (time >= 2){

            int RockIndex=Random.Range(0,2);
            float Rock_X=Random.Range(1,8);
            Instantiate(RockPre[RockIndex],new Vector3(Rock_X,0,0),transform.rotation);

            time=0;
        }

    }
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2