@mm2021 mm2021 / SpawnerBubble.cs
Created at Wed Jun 30 13:31:24 JST 2021
気泡の発生量を増やした
SpawnerBubble.cs
Raw
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);
    }
}
@s18h026 s18h026 commented on 11 Jul 2021

表面に気泡が発生するようにした
Scaleを簡略化した