Files
BeatSaber/Desktop/unity/work/BeatSabar/VRBeatSaber/Assets/Script/Spawner.cs
T

33 lines
872 B
C#
Raw Normal View History

2026-04-30 14:00:10 +09:00
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject[] cube;
public Transform[] point;
public float beat = 1;
float timer = 0f;
void Update()
{
if(timer > beat)
{
int c = Random.Range(0, 2);
int p = Random.Range(0, 4);
GameObject obj = Instantiate(cube[c], point[p].position, point[p].rotation);
//GameObject obj = Instantiate(cube[c], point[p]); //beatBox를 랜덤하게 생성
obj.transform.Rotate(transform.forward, 90 * Random.Range(0, 4));
//obj.transform.localPosition = Vector3.zero; //박스의 벡터(방향을 초기화)
//obj.transform.Rotate(transform.forward, 90 * Random.Range(0, 4)); //박스의 회전(방향, 회전률)
2026-04-30 14:00:10 +09:00
timer -= beat;
}
timer += Time.deltaTime;
}
}