using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move : MonoBehaviour
{
public float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.position += Vector3.left * speed * Time.deltaTime; // (-1,0,0)
}
}
6. 랜덤으로 파이프 만들어주기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MakePipe : MonoBehaviour
{
public GameObject pipe;
public float timeDiff;
float timer = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
timer += Time.deltaTime;
if (timer > timeDiff)
{
GameObject newpipe = Instantiate(pipe);
newpipe.transform.position = new Vector3(6,Random.Range(-1.7f, 3.0f),0);
// Instantiate(pipe);
timer = 0;
Destroy(newpipe, 10.0f);// 10초뒤 삭제
}
}
}