砲弾を破壊する/エフェクトを出す


砲弾の破壊とエフェクトの生成
using UnityEngine;
public class DestroyShell : MonoBehaviour
{
public GameObject effectPrefab;
private void OnCollisionEnter(Collision collision)
{
// 自分を破壊する
Destroy(gameObject);
// 爆発のエフェクトを出す
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
// エフェクトを消す
Destroy(effect, 1f);
}
}


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

砲弾の破壊とエフェクトの生成
using UnityEngine;
public class DestroyShell : MonoBehaviour
{
public GameObject effectPrefab;
private void OnCollisionEnter(Collision collision)
{
// 自分を破壊する
Destroy(gameObject);
// 爆発のエフェクトを出す
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
// エフェクトを消す
Destroy(effect, 1f);
}
}


砲弾を破壊する/エフェクトを出す