ボスの機能の作成①(コア)





コアの色を変化させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossCore : MonoBehaviour
{
public Material[] materials;
private int num = 0;
private void Start()
{
StartCoroutine(ChangeColor());
}
// コルーチン
private IEnumerator ChangeColor()
{
while (true)
{
yield return new WaitForSeconds(5f);
// 順送りのテクニック
num = (num + 1) % materials.Length;
// BossCoreの色を変化させる
this.gameObject.GetComponent<MeshRenderer>().material = materials[num];
}
}
}


【2021版】Danmaku(基礎/全55回)
他のコースを見る




コアの色を変化させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossCore : MonoBehaviour
{
public Material[] materials;
private int num = 0;
private void Start()
{
StartCoroutine(ChangeColor());
}
// コルーチン
private IEnumerator ChangeColor()
{
while (true)
{
yield return new WaitForSeconds(5f);
// 順送りのテクニック
num = (num + 1) % materials.Length;
// BossCoreの色を変化させる
this.gameObject.GetComponent<MeshRenderer>().material = materials[num];
}
}
}


ボスの機能の作成①(コア)