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

質問編集履歴

7

書式の改善

2018/07/26 15:02

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -89,4 +89,5 @@
89
89
  }
90
90
  }
91
91
  ```
92
- "yield return new WaitForSeconds (0.8f);"これで0.8秒待ち、その間に**パーティクルを出すことによってパーティクルを出すことができました**。しかし、その0.8秒の間tomatoは削除されないのでそこを、tomatoがpointというタグのオブジェクトに当たったらすぐに**削除&パーティクルを出す**ようにしたい。
92
+ "yield return new WaitForSeconds (0.8f);"これで0.8秒待ち、その間に**パーティクルを出すことによってパーティクルを出すことができました**。しかし、その0.8秒の間tomatoは削除されないのでそこを、tomatoがpointというタグのオブジェクトに当たったらすぐに**削除&パーティクルを出す**ようにしたい。
93
+ ご教授願います。

6

書式の改善

2018/07/26 15:02

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -33,7 +33,7 @@
33
33
  とエラーが出たので検索してみましたが、解決方法が記載されていませんでした。
34
34
  ご教授願います。
35
35
 
36
- ### 追記
36
+ ### 追記1
37
37
  ↓現在のprefab化されているオブジェクトにアタッチしているスクリプト
38
38
  ```c#
39
39
  using System.Collections;
@@ -59,4 +59,34 @@
59
59
  ↓tomatoにアタッチしているスクリプト、パーティクル
60
60
  ![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)
61
61
  ↓パーティクルの設定
62
- ![イメージ説明](e2e058388736ec8517ed47942e4025ab.png)
62
+ ![イメージ説明](e2e058388736ec8517ed47942e4025ab.png)
63
+ ### 追記2
64
+ tomatoに直接Particleをアタッチ。
65
+ ![イメージ説明](9eea7ba07044ca9e0efb642770a1fc63.png)
66
+ ↓tomatoにアタッチしているスクリプト
67
+ ```c#
68
+ using System.Collections;
69
+ using System.Collections.Generic;
70
+ using UnityEngine;
71
+
72
+ public class YasaiController : MonoBehaviour {
73
+ [SerializeField] ParticleSystem hosi;
74
+ public GameObject yasai;
75
+
76
+ void Start () {
77
+ hosi = GetComponent<ParticleSystem> (); //ここを追加
78
+ Debug.Log(hosi != null ? "ParticleSystemが子要素にアタッチされている" : "ParticleSystemが子要素にアタッチされていない");
79
+ }
80
+
81
+ IEnumerator OnCollisionEnter2D (Collision2D other) {
82
+ if (other.gameObject.tag == "point") {
83
+ hosi.Play ();
84
+
85
+ yield return new WaitForSeconds (0.8f); //0.8秒待つ。しかし、この間はオブジェクトは削除されない。それを改善したい。
86
+
87
+ Destroy (yasai);
88
+ }
89
+ }
90
+ }
91
+ ```
92
+ "yield return new WaitForSeconds (0.8f);"これで0.8秒待ち、その間に**パーティクルを出すことによってパーティクルを出すことができました**。しかし、その0.8秒の間tomatoは削除されないのでそこを、tomatoがpointというタグのオブジェクトに当たったらすぐに**削除&パーティクルを出す**ようにしたい。

5

書式の改善

2018/07/26 14:45

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -57,4 +57,6 @@
57
57
  }
58
58
  ```
59
59
  ↓tomatoにアタッチしているスクリプト、パーティクル
60
- ![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)
60
+ ![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)
61
+ ↓パーティクルの設定
62
+ ![イメージ説明](e2e058388736ec8517ed47942e4025ab.png)

4

書式の改善

2018/07/26 00:26

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -55,4 +55,6 @@
55
55
  }
56
56
  }
57
57
  }
58
- ```
58
+ ```
59
+ ↓tomatoにアタッチしているスクリプト、パーティクル
60
+ ![イメージ説明](8406d47d02a657a518d91f737b71f7d2.png)

3

書式の改善

2018/07/25 14:33

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -31,4 +31,28 @@
31
31
  YasaiController.Start () (at Assets/Scripts/YasaiController.cs:11)
32
32
 
33
33
  とエラーが出たので検索してみましたが、解決方法が記載されていませんでした。
34
- ご教授願います。
34
+ ご教授願います。
35
+
36
+ ### 追記
37
+ ↓現在のprefab化されているオブジェクトにアタッチしているスクリプト
38
+ ```c#
39
+ using System.Collections;
40
+ using System.Collections.Generic;
41
+ using UnityEngine;
42
+
43
+ public class YasaiController : MonoBehaviour {
44
+ [SerializeField] ParticleSystem hosi;
45
+
46
+ void Start () {
47
+ Debug.Log(hosi != null ? "ParticleSystemが子要素にアタッチされている" : "PParticleSystemが子要素にアタッチされていない");
48
+ hosi = GetComponentInChildren<ParticleSystem>();
49
+ }
50
+
51
+ void OnCollisionEnter2D (Collision2D other) {
52
+ if (other.gameObject.tag == "point") {
53
+ hosi.Play();
54
+ Destroy(yasai);
55
+ }
56
+ }
57
+ }
58
+ ```

2

書式の改善

2018/07/25 07:12

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
File without changes

1

誤字

2018/07/24 13:20

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- オブジェクトとプレイヤーが当たったらオブジェ削除したい
1
+ オブジェクトとプレイヤーが当たったらパーティ表示させたい
body CHANGED
@@ -1,4 +1,4 @@
1
- タイトルの通りオブジェクトとプレイヤーが当たったらオブジェ削除したいです。
1
+ タイトルの通りオブジェクトとプレイヤーが当たったらパーティ表示させたいです。
2
2
  オブジェクトは複数のprefab化されている物から一つだけをランダムで選び、それをゲーム画面に呼び出されています。
3
3
 
4
4
  ↓prefab化されているオブジェクトにアタッチしているスクリプト