質問編集履歴
7
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -181,3 +181,5 @@
|
|
181
181
|
```
|
182
182
|
|
183
183
|
"yield return new WaitForSeconds (0.8f);"これで0.8秒待ち、その間に**パーティクルを出すことによってパーティクルを出すことができました**。しかし、その0.8秒の間tomatoは削除されないのでそこを、tomatoがpointというタグのオブジェクトに当たったらすぐに**削除&パーティクルを出す**ようにしたい。
|
184
|
+
|
185
|
+
ご教授願います。
|
6
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
### 追記
|
71
|
+
### 追記1
|
72
72
|
|
73
73
|
↓現在のprefab化されているオブジェクトにアタッチしているスクリプト
|
74
74
|
|
@@ -121,3 +121,63 @@
|
|
121
121
|
↓パーティクルの設定
|
122
122
|
|
123
123
|
![イメージ説明](e2e058388736ec8517ed47942e4025ab.png)
|
124
|
+
|
125
|
+
### 追記2
|
126
|
+
|
127
|
+
tomatoに直接Particleをアタッチ。
|
128
|
+
|
129
|
+
![イメージ説明](9eea7ba07044ca9e0efb642770a1fc63.png)
|
130
|
+
|
131
|
+
↓tomatoにアタッチしているスクリプト
|
132
|
+
|
133
|
+
```c#
|
134
|
+
|
135
|
+
using System.Collections;
|
136
|
+
|
137
|
+
using System.Collections.Generic;
|
138
|
+
|
139
|
+
using UnityEngine;
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
public class YasaiController : MonoBehaviour {
|
144
|
+
|
145
|
+
[SerializeField] ParticleSystem hosi;
|
146
|
+
|
147
|
+
public GameObject yasai;
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
void Start () {
|
152
|
+
|
153
|
+
hosi = GetComponent<ParticleSystem> (); //ここを追加
|
154
|
+
|
155
|
+
Debug.Log(hosi != null ? "ParticleSystemが子要素にアタッチされている" : "ParticleSystemが子要素にアタッチされていない");
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
IEnumerator OnCollisionEnter2D (Collision2D other) {
|
162
|
+
|
163
|
+
if (other.gameObject.tag == "point") {
|
164
|
+
|
165
|
+
hosi.Play ();
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
yield return new WaitForSeconds (0.8f); //0.8秒待つ。しかし、この間はオブジェクトは削除されない。それを改善したい。
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
Destroy (yasai);
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
"yield return new WaitForSeconds (0.8f);"これで0.8秒待ち、その間に**パーティクルを出すことによってパーティクルを出すことができました**。しかし、その0.8秒の間tomatoは削除されないのでそこを、tomatoがpointというタグのオブジェクトに当たったらすぐに**削除&パーティクルを出す**ようにしたい。
|
5
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -117,3 +117,7 @@
|
|
117
117
|
↓tomatoにアタッチしているスクリプト、パーティクル
|
118
118
|
|
119
119
|
![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)
|
120
|
+
|
121
|
+
↓パーティクルの設定
|
122
|
+
|
123
|
+
![イメージ説明](e2e058388736ec8517ed47942e4025ab.png)
|
4
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -113,3 +113,7 @@
|
|
113
113
|
}
|
114
114
|
|
115
115
|
```
|
116
|
+
|
117
|
+
↓tomatoにアタッチしているスクリプト、パーティクル
|
118
|
+
|
119
|
+
![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)
|
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -65,3 +65,51 @@
|
|
65
65
|
とエラーが出たので検索してみましたが、解決方法が記載されていませんでした。
|
66
66
|
|
67
67
|
ご教授願います。
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
### 追記
|
72
|
+
|
73
|
+
↓現在のprefab化されているオブジェクトにアタッチしているスクリプト
|
74
|
+
|
75
|
+
```c#
|
76
|
+
|
77
|
+
using System.Collections;
|
78
|
+
|
79
|
+
using System.Collections.Generic;
|
80
|
+
|
81
|
+
using UnityEngine;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
public class YasaiController : MonoBehaviour {
|
86
|
+
|
87
|
+
[SerializeField] ParticleSystem hosi;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
void Start () {
|
92
|
+
|
93
|
+
Debug.Log(hosi != null ? "ParticleSystemが子要素にアタッチされている" : "PParticleSystemが子要素にアタッチされていない");
|
94
|
+
|
95
|
+
hosi = GetComponentInChildren<ParticleSystem>();
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
void OnCollisionEnter2D (Collision2D other) {
|
102
|
+
|
103
|
+
if (other.gameObject.tag == "point") {
|
104
|
+
|
105
|
+
hosi.Play();
|
106
|
+
|
107
|
+
Destroy(yasai);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
```
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
誤字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
オブジェクトとプレイヤーが当たったら
|
1
|
+
オブジェクトとプレイヤーが当たったらパーティクルを表示させたい
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
タイトルの通りオブジェクトとプレイヤーが当たったら
|
1
|
+
タイトルの通りオブジェクトとプレイヤーが当たったらパーティクルを表示させたいです。
|
2
2
|
|
3
3
|
オブジェクトは複数のprefab化されている物から一つだけをランダムで選び、それをゲーム画面に呼び出されています。
|
4
4
|
|