Last active
July 10, 2017 14:59
-
-
Save maco1028/487f3ef9141f9501a583 to your computer and use it in GitHub Desktop.
オブジェクトランダムに追加
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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