回答編集履歴

1

追記

2015/11/27 08:05

投稿

tanamochi
tanamochi

スコア83

test CHANGED
@@ -3,3 +3,129 @@
3
3
  型が違うよエラーが主なので扱っている型が正しいか確認しましょう。
4
4
 
5
5
  英語が読めなくてもweb翻訳などを使えばなんとなく意味はわかると思います。
6
+
7
+
8
+
9
+ 追記
10
+
11
+ ```C#
12
+
13
+ public class py : MonoBehaviour {
14
+
15
+
16
+
17
+ private bool isTriggeredcp1;
18
+
19
+ private bool isTriggeredpy;
20
+
21
+
22
+
23
+ // 基本的には1行1処理
24
+
25
+ // こういう省略の仕方は後で見たときわからなくなるのでもっとわかりやすい名前に
26
+
27
+ Object e;
28
+
29
+ Object e2;
30
+
31
+ Transform position;
32
+
33
+ Transform p;
34
+
35
+ Transform sMarker;
36
+
37
+ Transform eMarker;
38
+
39
+ GameObject Target;
40
+
41
+
42
+
43
+
44
+
45
+ void OnTriggerStay (Collider Other){
46
+
47
+ if (Other.tag == "E") {
48
+
49
+ // 基本的には1行1処理
50
+
51
+ isTriggeredpy = true;
52
+
53
+ isTriggeredcp1 = true;
54
+
55
+
56
+
57
+ // p は Transform なのに GameObject を代入
58
+
59
+ p = Other.transform.gameObject;
60
+
61
+ position = Other.transform.position;
62
+
63
+ }
64
+
65
+ }
66
+
67
+
68
+
69
+
70
+
71
+ // Use this for initialization
72
+
73
+ void Start () {
74
+
75
+ // cp って見て何かすぐにわかりますか?
76
+
77
+ Transform sMarker = GetComponent<cp1>().startMarker;
78
+
79
+ Transform eMarker = GetComponent<cp1> ().endMarker;
80
+
81
+
82
+
83
+ foreach (Transform child in transform)
84
+
85
+ {
86
+
87
+ GameObject gameObject = child.gameObject;
88
+
89
+ if (gameObject.tag == "collider") {
90
+
91
+ gameObject.renderer.enabled = false;
92
+
93
+ }
94
+
95
+ }
96
+
97
+ }
98
+
99
+
100
+
101
+ // Update is called once per frame
102
+
103
+ void Update () {
104
+
105
+
106
+
107
+ if (!isTriggeredcp1) {
108
+
109
+ // sg って見て何かすぐにわかりますか?
110
+
111
+ p.transform.Find("sg") = sMarker;
112
+
113
+ p.transform.Find("sg1") = eMarker;
114
+
115
+ }
116
+
117
+
118
+
119
+ if (!isTriggeredpy) {
120
+
121
+ Instantiate(e2,Vector3(position),Quaternion.identity);
122
+
123
+ Instantiate(e,Vector3(position),Quaternion.identity);
124
+
125
+ }
126
+
127
+ }
128
+
129
+ }
130
+
131
+ ```