★敵をデザインする



敵を破壊する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHP : MonoBehaviour
{
public GameObject effectPrefab;
public int scoreValue;
private ScoreManager sm;
void Start()
{
sm = GameObject.Find("ScoreLabel").GetComponent<ScoreManager>();
}
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Shell"))
{
Destroy(other.gameObject);
Destroy(gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.5f);
sm.AddScore(scoreValue);
}
}
}



敵を破壊する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHP : MonoBehaviour
{
public GameObject effectPrefab;
public int scoreValue;
private ScoreManager sm;
void Start()
{
sm = GameObject.Find("ScoreLabel").GetComponent<ScoreManager>();
}
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Shell"))
{
Destroy(other.gameObject);
Destroy(gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.5f);
sm.AddScore(scoreValue);
}
}
}
★敵をデザインする