GameManager.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public GameObject[] targetArray; private int count; private float time; private int vecY; //Y座標を入れる変数 void Start() { count = 0; } void Update() { time -= Time.deltaTime; if(time <= 0.0f) { vecY = Random.Range(0,12); //0~12でランダムの値を取得 //Y座標をランダム(vecY)にする Instantiate(targetArray[count],new Vector3(-40, vecY, 30),Quaternion.identity); time = 5.0f; count++; } } } |