teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

[

2018/12/04 06:34

投稿

fiveHundred
fiveHundred

スコア10454

answer CHANGED
@@ -49,4 +49,6 @@
49
49
 
50
50
  追記2:
51
51
 
52
- ![イメージ説明](6b3e67949a9d5b45ff0d190dc44e2e88.png)
52
+ ![イメージ説明](6b3e67949a9d5b45ff0d190dc44e2e88.png)
53
+
54
+ ※設定後、ヒエラルキーのゲームオブジェクト(Particle System)は消して大丈夫です。

2

追記2

2018/12/04 06:34

投稿

fiveHundred
fiveHundred

スコア10454

answer CHANGED
@@ -43,4 +43,10 @@
43
43
  Destroy(gameObject);
44
44
  }
45
45
  }
46
- ```
46
+ ```
47
+
48
+ ---
49
+
50
+ 追記2:
51
+
52
+ ![イメージ説明](6b3e67949a9d5b45ff0d190dc44e2e88.png)

1

追記

2018/12/04 06:30

投稿

fiveHundred
fiveHundred

スコア10454

answer CHANGED
@@ -2,4 +2,45 @@
2
2
  public ParticleSystem m_particleSystem;
3
3
  ```
4
4
 
5
- 上記が設定されていない、あるいは設定が正しくないのだと思われます。
5
+ 上記が設定されていない、あるいは設定が正しくないのだと思われます。
6
+
7
+ ---
8
+
9
+ 追記:
10
+
11
+ ParticleSystemをアタッチしたプレハブを用意しておき、そのプレハブからゲームオブジェクトを生成するというのはどうでしょうか。
12
+
13
+ ```C#
14
+ using System.Collections;
15
+ using System.Collections.Generic;
16
+ using UnityEngine;
17
+
18
+ public class BulletController : MonoBehaviour
19
+ {
20
+ public GameObject m_particleSystem; // ParticleSystemをアタッチしているプレハブを設定
21
+
22
+ // Use this for initialization
23
+ void Start ()
24
+ {
25
+
26
+ }
27
+
28
+ void Update()
29
+ {
30
+ transform.Translate(0, 0.2f, 0);
31
+
32
+ if (transform.position.y > 5)
33
+ {
34
+ Destroy(gameObject);
35
+ }
36
+ }
37
+
38
+ void OnTriggerEnter2D(Collider2D coll)
39
+ {
40
+ GameObject obj = Instantiate(m_particleSystem, transform.position, Quaternion.identity);
41
+ obj.GetComponent<ParticleSystem>().Play();
42
+ Destroy(coll.gameObject);
43
+ Destroy(gameObject);
44
+ }
45
+ }
46
+ ```