using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class SpawnerBubble : MonoBehaviour
{
[SerializeField] private GameObject denkyoku;
public GameObject bubble;
//ここでpublicと宣言することで後でInspectorビューから操作できる
float timer = 0;
float spowntime = 1; //2秒ごとに生成させる
private void Update()
{
timer += Time.deltaTime; //timerの値を1秒に1のペースで増やす
if (timer > spowntime)
{
PlaneGenerate(); //PlaneGenerate関数を呼び出す。
timer = 0; //timerを0に戻す。
}
}
private void PlaneGenerate()
{
var distanceVector = new Vector3(1, 0);
var spawnPositionFromDenkyoku = Quaternion.Euler(0, Random.Range(0, 360f), 0) * distanceVector;
var denkyokuPosition = denkyoku.transform.position + spawnPositionFromDenkyoku;
var spawnPosition = new Vector3(denkyokuPosition.x, denkyokuPosition.y, denkyokuPosition.z);
Instantiate(bubble, spawnPosition, Quaternion.identity);
// Instantiate(bubble, spawnPosition, Quaternion.identity);
}
}
表面に気泡が発生するようにした
Scaleを簡略化した