壁などに当たったFireBallを破壊する

FireBallの破壊
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyFireBall : MonoBehaviour
{
public GameObject effectPrefab;
private void OnCollisionEnter2D(Collision2D collision)
{
Destroy(this.gameObject); // 何かに衝突したらFireBallを破壊する
// 衝突時にエフェクトを出す。
// このエフェクトは、エフェクト側で「自動削除」のスクリプトを追加しておくこと(重要)
Instantiate(effectPrefab, transform.position, Quaternion.identity);
}
}





【2022版】DarkCastle(全39回)
他のコースを見る
FireBallの破壊
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyFireBall : MonoBehaviour
{
public GameObject effectPrefab;
private void OnCollisionEnter2D(Collision2D collision)
{
Destroy(this.gameObject); // 何かに衝突したらFireBallを破壊する
// 衝突時にエフェクトを出す。
// このエフェクトは、エフェクト側で「自動削除」のスクリプトを追加しておくこと(重要)
Instantiate(effectPrefab, transform.position, Quaternion.identity);
}
}





壁などに当たったFireBallを破壊する