アニメーション3/アニメーションからメソッドの実行を行う



爆発のメソッド
using UnityEngine;
public class Bomb : MonoBehaviour
{
public GameObject effectPrefab;
public AudioClip sound;
// 頭に「public」を付けること(重要ポイント)
public void Explosion()
{
Destroy(gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.0f);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
}
}






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


爆発のメソッド
using UnityEngine;
public class Bomb : MonoBehaviour
{
public GameObject effectPrefab;
public AudioClip sound;
// 頭に「public」を付けること(重要ポイント)
public void Explosion()
{
Destroy(gameObject);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
Destroy(effect, 1.0f);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
}
}






アニメーション3/アニメーションからメソッドの実行を行う