敵の作成①(デザイン&HPの設定)


敵のHP
using UnityEngine;
public class EnemyHP : MonoBehaviour
{
public int HP;
public GameObject effectPrefab;
public AudioClip sound;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("PlayerMissile"))
{
HP -= 1;
Destroy(other.gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.0f);
if (HP < 1)
{
Destroy(this.gameObject);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
}
}
}
}



【Unity6版】Danmaku(全20回)
他のコースを見る

敵のHP
using UnityEngine;
public class EnemyHP : MonoBehaviour
{
public int HP;
public GameObject effectPrefab;
public AudioClip sound;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("PlayerMissile"))
{
HP -= 1;
Destroy(other.gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.0f);
if (HP < 1)
{
Destroy(this.gameObject);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
}
}
}
}



敵の作成①(デザイン&HPの設定)