public class ballMove : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position += Vector3.back * Time.deltaTime * speed;
// Vector3.back 반대방향으로 오게 함
}
}
public class ballCopy : MonoBehaviour {
public GameObject ball;
Vector3 pos;
// Use this for initialization
void Start () {
StartCoroutine(Sleep());
}
IEnumerator Sleep()
{
while (true) {
int randx= Random.Range(-10, 10);
int randy= Random.Range(2, 10);
pos = new Vector3 (randx,randy,30);
Instantiate (ball,pos, Quaternion.LookRotation(Vector3.back));
//복제코드
//Quaternion.LookRotation(Vector3.back) 반대방향으로 바라보게 함
yield return new WaitForSeconds (2.0f);
// 2초간 딜레이로 복제
}
}
}
'Programing > unity' 카테고리의 다른 글
유니티,unity,키를 누를때 회전,nput.GetKey,KeyCode,transform.Rotate (0) | 2017.02.24 |
---|---|
unity,유니티,transform.position. z 값 사용,GameObject 선언 (0) | 2017.02.23 |
unity,유니티,1초에 한번씩 오브젝트 복제,IEnumerator ,StartCoroutine,WaitForSeconds (0) | 2017.02.23 |
유니티,unity,z방향으로 초당 이동,Vector3.forward,Time.deltaTime (0) | 2017.02.23 |
unity,Space 키 입력시 오브젝트 복사 (0) | 2017.02.21 |