(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHP : MonoBehaviour
{
private int HP = 300;
// ★HSV値の動的変更
private Renderer rendererX;
private float h_value;
private void Start()
{
rendererX = GetComponent<MeshRenderer>();
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Shell"))
{
HP -= 1;
if (HP < 1)
{
Destroy(gameObject);
}
// ★HSV値の動的変更
h_value += 0.01f;
rendererX.material.color = Color.HSVToRGB(h_value, 1, 1);
}
}
}
(実行結果)