質問編集履歴

2

タイトル編集

2021/01/27 14:04

投稿

SL_Looty1
SL_Looty1

スコア2

test CHANGED
@@ -1 +1 @@
1
- unity) Prefabで作った的に当たった時スコアを更新する
1
+ unity)3D的あてゲーム  Prefabで作った的に当たった時スコアを更新する
test CHANGED
File without changes

1

ジェネレーターのスクリプト追記

2021/01/27 14:04

投稿

SL_Looty1
SL_Looty1

スコア2

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
- 3Dで作った的あてゲームにおいてPrefabを使って的を作成したのですがテキストがうまく接続できずスコアが加算されません
1
+ unity初心者です。3Dで作った的あてゲームにおいてPrefabを使って的を作成したのですがテキストがうまく接続できずスコアが加算されません
2
+
3
+ Prefabにする前はスコアは加算されていました
2
4
 
3
5
 
4
6
 
@@ -70,6 +72,90 @@
70
72
 
71
73
  }
72
74
 
75
+ /////////////////////////////////////////////////////////////////////////////////////////////////
76
+
77
+ using System.Collections;
78
+
79
+ using System.Collections.Generic;
80
+
81
+ using UnityEngine;
82
+
83
+ using UnityEngine.UI;
84
+
85
+
86
+
87
+
88
+
89
+ public class matoGen : MonoBehaviour
90
+
91
+ {
92
+
93
+ public GameObject mato;
94
+
95
+ int count = 0;
96
+
97
+ int max = 99;
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ // Start is called before the first frame update
108
+
109
+ void Start()
110
+
111
+ {
112
+
113
+
114
+
115
+ InvokeRepeating("Generate", 1, 6);
116
+
117
+
118
+
119
+ }
120
+
121
+
122
+
123
+ // Update is called once per frame
124
+
125
+ void Update()
126
+
127
+ {
128
+
129
+
130
+
131
+ }
132
+
133
+ void Generate()
134
+
135
+ {
136
+
137
+ if (count == max) return;
138
+
139
+ float x = Random.Range(-2.5f, 2.5f);
140
+
141
+ float y = Random.Range(6f,9f);
142
+
143
+ float z = 7;
144
+
145
+ Vector3 position = new Vector3(x, y, z);
146
+
147
+ Instantiate(mato, new Vector3(x,y,z), Quaternion.Euler(90,0,0));
148
+
149
+ count++;
150
+
151
+ }
152
+
153
+ }
154
+
155
+
156
+
157
+ 上が的本体のスクリプトで下がジェネレーターのスクリプトです
158
+
73
159
 
74
160
 
75
161
  ```ここに言語名を入力
@@ -84,8 +170,6 @@
84
170
 
85
171
 
86
172
 
87
- CanvasのscoreテキストをPrefab化した後に的にアyとれっと接続してみた結果、接続はできたのですがスコアは何も変わりませんでした
88
-
89
173
 
90
174
 
91
175
  ### 補足情報(FW/ツールのバージョンなど)