質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,630 @@
|
|
1
|
+
```c```ここに言語を入力
|
2
|
+
|
3
|
+
using System.Collections;
|
4
|
+
|
5
|
+
using System.Collections.Generic;
|
6
|
+
|
7
|
+
using UnityEngine;
|
8
|
+
|
9
|
+
using UnityEngine.UI;
|
10
|
+
|
11
|
+
public class boost:MonoBehaviour
|
12
|
+
|
13
|
+
{
|
14
|
+
|
15
|
+
public GameObject score_object = null;
|
16
|
+
|
17
|
+
public GameObject bulletPrefab;
|
18
|
+
|
19
|
+
public float shotSpeed;
|
20
|
+
|
21
|
+
public int shotCount = 30;
|
22
|
+
|
23
|
+
private float shotInterval;
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
void Update()
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
if (Input.GetKey(KeyCode.Space ))
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
shotInterval += 1;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
if (shotInterval % 5 == 0 && shotCount > 0)
|
42
|
+
|
43
|
+
{
|
44
|
+
|
45
|
+
shotCount -= 1;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
GameObject bullet = (GameObject)Instantiate(bulletPrefab, transform.position, Quaternion.Euler(transform.parent.eulerAngles.x, transform.parent.eulerAngles.y, 0));
|
50
|
+
|
51
|
+
Rigidbody bulletRb = bullet.GetComponent<Rigidbody>();
|
52
|
+
|
53
|
+
bulletRb.AddForce(transform.forward * shotSpeed);
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
//射撃されてから3秒後に銃弾のオブジェクトを破壊する.
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Destroy(bullet, 0.2f);
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
else if (Input.GetKeyDown(KeyCode.R))
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
shotCount = 300;
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
Text score_text = score_object.GetComponent<Text>();
|
80
|
+
|
81
|
+
// テキストの表示を入れ替える
|
82
|
+
|
83
|
+
score_text.text = "fuel" + shotCount;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
```c
|
98
|
+
|
99
|
+
using System.Collections;
|
100
|
+
|
101
|
+
using System.Collections.Generic;
|
102
|
+
|
103
|
+
using UnityEngine;
|
104
|
+
|
105
|
+
using UnityEngine.AI;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
public class Chase : MonoBehaviour
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
public GameObject target;
|
114
|
+
|
115
|
+
private NavMeshAgent agent;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
void Start()
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
agent = GetComponent<NavMeshAgent>();
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
void Update()
|
130
|
+
|
131
|
+
{
|
132
|
+
|
133
|
+
// ターゲットの位置を目的地に設定する。
|
134
|
+
|
135
|
+
agent.destination = target.transform.position;
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
c
|
144
|
+
|
145
|
+
using System.Collections;
|
146
|
+
|
147
|
+
using System.Collections.Generic;
|
148
|
+
|
149
|
+
using UnityEngine;
|
150
|
+
|
151
|
+
using System.Collections;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
public class oto : MonoBehaviour
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
private AudioSource sound01;
|
160
|
+
|
161
|
+
private AudioSource sound02;
|
162
|
+
|
163
|
+
void Start()
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
//AudioSourceコンポーネントを取得し、変数に格納
|
168
|
+
|
169
|
+
AudioSource[] audioSources = GetComponents<AudioSource>();
|
170
|
+
|
171
|
+
sound01 = audioSources[0];
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
void Update()
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
//指定のキーが押されたら音声ファイル再生
|
182
|
+
|
183
|
+
if (Input.GetKey(KeyCode.Mouse0))
|
184
|
+
|
185
|
+
{
|
186
|
+
|
187
|
+
sound01.PlayOneShot(sound01.clip);
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
if (Input.GetKey(KeyCode.Space))
|
192
|
+
|
193
|
+
{
|
194
|
+
|
195
|
+
sound02.PlayOneShot(sound02.clip);
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
c
|
208
|
+
|
209
|
+
using System.Collections;
|
210
|
+
|
211
|
+
using System.Collections.Generic;
|
212
|
+
|
213
|
+
using UnityEngine;
|
214
|
+
|
215
|
+
using System.Collections;
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
public class oto2 : MonoBehaviour
|
220
|
+
|
221
|
+
{
|
222
|
+
|
223
|
+
private AudioSource sound01;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
void Start()
|
228
|
+
|
229
|
+
{
|
230
|
+
|
231
|
+
//AudioSourceコンポーネントを取得し、変数に格納
|
232
|
+
|
233
|
+
sound01 = GetComponent<AudioSource>();
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
void Update()
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
//指定のキーが押されたら音声ファイル再生
|
244
|
+
|
245
|
+
if (Input.GetKey(KeyCode.Space))
|
246
|
+
|
247
|
+
{
|
248
|
+
|
249
|
+
sound01.PlayOneShot(sound01.clip);
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
c
|
258
|
+
|
259
|
+
using System.Collections;
|
260
|
+
|
261
|
+
using System.Collections.Generic;
|
262
|
+
|
263
|
+
using UnityEngine;
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
public class Seisei : MonoBehaviour
|
268
|
+
|
269
|
+
{
|
270
|
+
|
271
|
+
// 出現させる敵を入れておく
|
272
|
+
|
273
|
+
[SerializeField] GameObject[] enemys;
|
274
|
+
|
275
|
+
// 次に敵が出現するまでの時間
|
276
|
+
|
277
|
+
[SerializeField] float appearNextTime;
|
278
|
+
|
279
|
+
// この場所から出現する敵の数
|
280
|
+
|
281
|
+
[SerializeField] int maxNumOfEnemys;
|
282
|
+
|
283
|
+
// 今何人の敵を出現させたか(総数)
|
284
|
+
|
285
|
+
private int numberOfEnemys;
|
286
|
+
|
287
|
+
// 待ち時間計測フィールド
|
288
|
+
|
289
|
+
private float elapsedTime;
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
// Use this for initialization
|
294
|
+
|
295
|
+
void Start()
|
296
|
+
|
297
|
+
{
|
298
|
+
|
299
|
+
numberOfEnemys = 0;
|
300
|
+
|
301
|
+
elapsedTime = 0f;
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
void Update()
|
306
|
+
|
307
|
+
{
|
308
|
+
|
309
|
+
// この場所から出現する最大数を超えてたら何もしない
|
310
|
+
|
311
|
+
if (numberOfEnemys >= maxNumOfEnemys)
|
312
|
+
|
313
|
+
{
|
314
|
+
|
315
|
+
return;
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
// 経過時間を足す
|
320
|
+
|
321
|
+
elapsedTime += Time.deltaTime;
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
// 経過時間が経ったら
|
326
|
+
|
327
|
+
if (elapsedTime > appearNextTime)
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
elapsedTime = 0f;
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
AppearEnemy();
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
void AppearEnemy()
|
342
|
+
|
343
|
+
{
|
344
|
+
|
345
|
+
// 出現させる敵をランダムに選ぶ
|
346
|
+
|
347
|
+
var randomValue = Random.Range(0, enemys.Length);
|
348
|
+
|
349
|
+
// 敵の向きをランダムに決定
|
350
|
+
|
351
|
+
var randomRotationY = Random.value * 360f;
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
GameObject.Instantiate(enemys[randomValue], transform.position, Quaternion.Euler(0f, randomRotationY, 0f));
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
numberOfEnemys++;
|
360
|
+
|
361
|
+
elapsedTime = 0f;
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
c
|
370
|
+
|
371
|
+
using System.Collections;
|
372
|
+
|
373
|
+
using System.Collections.Generic;
|
374
|
+
|
375
|
+
using UnityEngine;
|
376
|
+
|
377
|
+
using UnityEngine.UI;
|
378
|
+
|
379
|
+
public class Shooting : MonoBehaviour
|
380
|
+
|
381
|
+
{
|
382
|
+
|
383
|
+
public GameObject score_object = null;
|
384
|
+
|
385
|
+
public GameObject bulletPrefab;
|
386
|
+
|
387
|
+
public float shotSpeed;
|
388
|
+
|
389
|
+
public int shotCount = 30;
|
390
|
+
|
391
|
+
private float shotInterval;
|
392
|
+
|
393
|
+
public Explosion m_explosionPrefab;
|
394
|
+
|
395
|
+
public AudioClip audioClip1;
|
396
|
+
|
397
|
+
private AudioSource audioSource;
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
void Update()
|
402
|
+
|
403
|
+
{
|
404
|
+
|
405
|
+
if (Input.GetKey(KeyCode.Mouse0))
|
406
|
+
|
407
|
+
{
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
shotInterval += 1;
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
if (shotInterval % 5 == 0 && shotCount > 0)
|
416
|
+
|
417
|
+
{
|
418
|
+
|
419
|
+
shotCount -= 1;
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
GameObject bullet = (GameObject)Instantiate(bulletPrefab, transform.position, Quaternion.Euler(transform.parent.eulerAngles.x, transform.parent.eulerAngles.y, 0));
|
424
|
+
|
425
|
+
Rigidbody bulletRb = bullet.GetComponent<Rigidbody>();
|
426
|
+
|
427
|
+
bulletRb.AddForce(transform.forward * shotSpeed);
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
//射撃されてから3秒後に銃弾のオブジェクトを破壊する.
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
Destroy(bullet, 3.0f);
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
else if (Input.GetKeyDown(KeyCode.R))
|
446
|
+
|
447
|
+
{
|
448
|
+
|
449
|
+
shotCount = 30;
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
Text score_text = score_object.GetComponent<Text>();
|
456
|
+
|
457
|
+
// テキストの表示を入れ替える
|
458
|
+
|
459
|
+
score_text.text = "bullet" + shotCount;
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
}
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
c
|
474
|
+
|
475
|
+
using System.Collections;
|
476
|
+
|
477
|
+
using System.Collections.Generic;
|
478
|
+
|
479
|
+
using UnityEngine;
|
480
|
+
|
481
|
+
using UnityEngine.SceneManagement;
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
public class teki : MonoBehaviour
|
486
|
+
|
487
|
+
{
|
488
|
+
|
489
|
+
// Start is called before the first frame update
|
490
|
+
|
491
|
+
void Start()
|
492
|
+
|
493
|
+
{
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
void OnTriggerEnter(Collider other)
|
500
|
+
|
501
|
+
{
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
//ぶつかったオブジェクトのTagにShellという名前が書いてあったならば(条件).
|
506
|
+
|
507
|
+
if (other.CompareTag("teki"))
|
508
|
+
|
509
|
+
{
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
//HPクラスのDamage関数を呼び出す
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
//ぶつかってきたオブジェクトを破壊する.
|
520
|
+
|
521
|
+
SceneManager.LoadScene("result");
|
522
|
+
|
523
|
+
}
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
c
|
532
|
+
|
533
|
+
using System.Collections;
|
534
|
+
|
535
|
+
using System.Collections.Generic;
|
536
|
+
|
537
|
+
using UnityEngine;
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
public class Explosion : MonoBehaviour
|
542
|
+
|
543
|
+
{
|
544
|
+
|
545
|
+
private void Start()
|
546
|
+
|
547
|
+
{
|
548
|
+
|
549
|
+
// 演出が完了したら削除する
|
550
|
+
|
551
|
+
var particleSystem = GetComponent<ParticleSystem>();
|
552
|
+
|
553
|
+
Destroy(gameObject, particleSystem.main.duration);
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
c
|
562
|
+
|
563
|
+
using System.Collections;
|
564
|
+
|
565
|
+
using System.Collections.Generic;
|
566
|
+
|
567
|
+
using UnityEngine;
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
public class bakuhatsu : MonoBehaviour
|
574
|
+
|
575
|
+
{
|
576
|
+
|
577
|
+
private AudioSource audioSource;
|
578
|
+
|
579
|
+
public AudioClip audioClip1;
|
580
|
+
|
581
|
+
public Explosion m_explosionPrefab;
|
582
|
+
|
583
|
+
// Start is called before the first frame update
|
584
|
+
|
585
|
+
void Start()
|
586
|
+
|
587
|
+
{
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
}
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
// Update is called once per frame
|
596
|
+
|
597
|
+
void Update()
|
598
|
+
|
599
|
+
{if (Input.GetKey(KeyCode.Mouse0)) ;
|
600
|
+
|
601
|
+
Instantiate(
|
602
|
+
|
603
|
+
m_explosionPrefab,
|
604
|
+
|
605
|
+
transform.localPosition,
|
606
|
+
|
607
|
+
Quaternion.identity);
|
608
|
+
|
609
|
+
audioSource = gameObject.GetComponent<AudioSource>();
|
610
|
+
|
611
|
+
audioSource.clip = audioClip1;
|
612
|
+
|
613
|
+
audioSource.Play();
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
}
|
618
|
+
|
619
|
+
}
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
```
|
624
|
+
|
625
|
+
```
|
626
|
+
|
1
|
-
unityでc#でゲームを作っているのですが、先ほどunityのパッケージをインポートして再生しよう
|
627
|
+
```unityでc#でfpsゲームを作っているのですが、先ほどunityのパッケージをインポートして再生しよう
|
2
628
|
|
3
629
|
としたら
|
4
630
|
|
@@ -10,16 +636,6 @@
|
|
10
636
|
|
11
637
|
|
12
638
|
|
13
|
-
(3) PlayerSettings Validation: Requested build target group (20) doesn't exist; #define symbols for scripting won't be added.
|
14
|
-
|
15
|
-
UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)
|
16
|
-
|
17
|
-
UnityStandardAssets.CrossPlatformInput.Inspector.CrossPlatformInitialize:SetEnabled(String, Boolean, Boolean) (at Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs:127)
|
18
|
-
|
19
|
-
UnityStandardAssets.CrossPlatformInput.Inspector.CrossPlatformInitialize:.cctor() (at Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs:22)
|
20
|
-
|
21
|
-
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes(Type[])
|
22
|
-
|
23
639
|
|
24
640
|
|
25
641
|
と出てきてしまいます。初心者なのでよくわかりません。なので
|