Skip to content

Instantly share code, notes, and snippets.

@maco1028
Last active July 10, 2017 14:59
Show Gist options
  • Save maco1028/487f3ef9141f9501a583 to your computer and use it in GitHub Desktop.
Save maco1028/487f3ef9141f9501a583 to your computer and use it in GitHub Desktop.
オブジェクトランダムに追加
using UnityEngine;
using System.Collections;
public class Destory_obj : MonoBehaviour {
public GameObject obj;
void Awake(){
InvokeRepeating ("Create", Random.Range(3.0f,5.0f), Random.Range(3.0f,5.0f));
}
void Create()
{
//if(GUI.Button(new Rect(10, 10, 100, 50), "GENERATE")){
float x = Random.Range(-2.0f, 2.0f);
float y = Random.Range(5.0f, 10.0f);
float z = Random.Range(-2.0f, 2.0f);
float WaitTime;
GameObject[] Gameobj = GameObject.FindGameObjectsWithTag ("Object");
Instantiate(this.obj, new Vector3(x, y, z), Quaternion.identity);
//タグオブジェクトを削除
foreach(GameObject obs in Gameobj){
Destroy(obs);
}
//}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment