質問編集履歴
2
書式
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
Trail Rendererのマテリアルを指定して変更するプログラムはどのように書けばよいのでしょうか。
|
6
|
+
|
7
|
+
```
|
6
8
|
|
7
9
|
using System.Collections;
|
8
10
|
|
1
BoiceMove全文
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,19 +4,109 @@
|
|
4
4
|
|
5
5
|
Trail Rendererのマテリアルを指定して変更するプログラムはどのように書けばよいのでしょうか。
|
6
6
|
|
7
|
+
using System.Collections;
|
8
|
+
|
9
|
+
using System.Collections.Generic;
|
10
|
+
|
11
|
+
using UnityEngine;
|
7
12
|
|
8
13
|
|
9
|
-
```BoiceMove
|
10
14
|
|
15
|
+
[RequireComponent(typeof(Rigidbody))]
|
16
|
+
|
17
|
+
public class BoiceMove : MonoBehaviour {
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
private Rigidbody physics = null;
|
22
|
+
|
23
|
+
public Material[] _material; // 割り当てるマテリアル.
|
24
|
+
|
25
|
+
GameObject fire,thuder,freese;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
public void Awake()
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
this.physics = this.GetComponent<Rigidbody>();
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
11
|
-
public void FlipThunder()
|
43
|
+
public void FlipThunder()
|
12
44
|
|
13
45
|
{
|
14
46
|
|
15
47
|
this.GetComponent<Renderer>().material = _material[0];
|
16
48
|
|
49
|
+
GameObject prefab1 = (GameObject)Resources.Load("ErekiBall2");
|
50
|
+
|
51
|
+
thuder = Instantiate(prefab1, this.transform.position, Quaternion.identity);
|
52
|
+
|
53
|
+
//GetComponent<TrailRenderer>().material = _material[0];
|
54
|
+
|
55
|
+
StartCoroutine(Gogo());
|
56
|
+
|
57
|
+
Destroy(thuder, 1f);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
public void FlipFire()
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
this.GetComponent<Renderer>().material = _material[1];
|
68
|
+
|
69
|
+
GameObject prefab2 = (GameObject)Resources.Load("FlamesParticleEffect");
|
70
|
+
|
71
|
+
fire = Instantiate(prefab2, this.transform.position, Quaternion.identity);
|
72
|
+
|
73
|
+
//GetComponent<TrailRenderer>().material = _material[1];
|
74
|
+
|
75
|
+
StartCoroutine(Gogo());
|
76
|
+
|
77
|
+
Destroy(fire, 1f);
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
public void FlipFreese()
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
this.GetComponent<Renderer>().material = _material[2];
|
88
|
+
|
89
|
+
GameObject prefab3 = (GameObject)Resources.Load("Smoke");
|
90
|
+
|
91
|
+
freese = Instantiate(prefab3, this.transform.position, Quaternion.identity);
|
92
|
+
|
93
|
+
//GetComponent<TrailRenderer>().material = _material[2];
|
94
|
+
|
95
|
+
StartCoroutine(Gogo());
|
96
|
+
|
97
|
+
Destroy(freese, 1f);
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
IEnumerator Gogo()
|
104
|
+
|
105
|
+
{
|
106
|
+
|
107
|
+
yield return new WaitForSeconds(1f);
|
108
|
+
|
17
109
|
GetComponent<TrailRenderer>().enabled = true;
|
18
|
-
|
19
|
-
GetComponent<TrailRenderer>().material = _material[0];
|
20
110
|
|
21
111
|
this.physics.AddForce(new Vector3(0, 0, 1000f));
|
22
112
|
|
@@ -24,19 +114,7 @@
|
|
24
114
|
|
25
115
|
|
26
116
|
|
27
|
-
public void FlipFire()
|
28
|
-
|
29
|
-
{
|
30
|
-
|
31
|
-
this.GetComponent<Renderer>().material = _material[1];
|
32
|
-
|
33
|
-
GetComponent<TrailRenderer>().enabled = true;
|
34
|
-
|
35
|
-
GetComponent<TrailRenderer>().material = _material[1];
|
36
|
-
|
37
|
-
this.physics.AddForce(new Vector3(0, 0, 1000f));
|
38
|
-
|
39
|
-
|
117
|
+
}
|
40
118
|
|
41
119
|
```
|
42
120
|
|