前提・実現したいこと
unityを最近使い始めました
発生している問題・エラーメッセージ
UnassignedReferenceException: The variable m_particleSystem of BulletController has not been assigned.
You probably need to assign the m_particleSystem variable of the BulletController script in the inspector.
UnityEngine.ParticleSystem.Play () (at C:/buildslave/unity/build/artifacts/generated/bindings_old/common/ParticleSystem/ParticleSystemBindings.gen.cs:3287)
BulletController.OnTriggerEnter2D (UnityEngine.Collider2D coll) (at Assets/script/BulletController.cs:27)
該当のソースコード
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class BulletController : MonoBehaviour 6{ 7 public ParticleSystem m_particleSystem; 8 9 // Use this for initialization 10 void Start () 11 { 12 13 } 14 15 void Update() 16 { 17 transform.Translate(0, 0.2f, 0); 18 19 if (transform.position.y > 5) 20 { 21 Destroy(gameObject); 22 } 23 } 24 25 void OnTriggerEnter2D(Collider2D coll) 26 { 27 m_particleSystem.Play(); 28 Destroy(coll.gameObject); 29 Destroy(gameObject); 30 } 31}
試したこと
ヒエラルキーのパーティクルシステムを直接アタッチ
projectにもってきてプレハブ化してからアタッチ
補足情報(FW/ツールのバージョンなど)
unityの最新バージョンでゲーム作りの勉強を始めたのですが、入門サイトのアセットストが使えず仕方なくエフェクトを調べながら登録したのですが(ヒエラルキーのパーティクルシステム)これをscriptで扱う方法が分かりません
調べてもアタッチしたのち公書くみたいなものばかりでどうすれば関連付けられるのかを教えてくださいm(__)m
回答1件
あなたの回答
tips
プレビュー