回答編集履歴
1
追記
answer
CHANGED
@@ -1,3 +1,66 @@
|
|
1
1
|
変数宣言の部分をもう少し見やすく書きましょう。
|
2
2
|
型が違うよエラーが主なので扱っている型が正しいか確認しましょう。
|
3
|
-
英語が読めなくてもweb翻訳などを使えばなんとなく意味はわかると思います。
|
3
|
+
英語が読めなくてもweb翻訳などを使えばなんとなく意味はわかると思います。
|
4
|
+
|
5
|
+
追記
|
6
|
+
```C#
|
7
|
+
public class py : MonoBehaviour {
|
8
|
+
|
9
|
+
private bool isTriggeredcp1;
|
10
|
+
private bool isTriggeredpy;
|
11
|
+
|
12
|
+
// 基本的には1行1処理
|
13
|
+
// こういう省略の仕方は後で見たときわからなくなるのでもっとわかりやすい名前に
|
14
|
+
Object e;
|
15
|
+
Object e2;
|
16
|
+
Transform position;
|
17
|
+
Transform p;
|
18
|
+
Transform sMarker;
|
19
|
+
Transform eMarker;
|
20
|
+
GameObject Target;
|
21
|
+
|
22
|
+
|
23
|
+
void OnTriggerStay (Collider Other){
|
24
|
+
if (Other.tag == "E") {
|
25
|
+
// 基本的には1行1処理
|
26
|
+
isTriggeredpy = true;
|
27
|
+
isTriggeredcp1 = true;
|
28
|
+
|
29
|
+
// p は Transform なのに GameObject を代入
|
30
|
+
p = Other.transform.gameObject;
|
31
|
+
position = Other.transform.position;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
// Use this for initialization
|
37
|
+
void Start () {
|
38
|
+
// cp って見て何かすぐにわかりますか?
|
39
|
+
Transform sMarker = GetComponent<cp1>().startMarker;
|
40
|
+
Transform eMarker = GetComponent<cp1> ().endMarker;
|
41
|
+
|
42
|
+
foreach (Transform child in transform)
|
43
|
+
{
|
44
|
+
GameObject gameObject = child.gameObject;
|
45
|
+
if (gameObject.tag == "collider") {
|
46
|
+
gameObject.renderer.enabled = false;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
// Update is called once per frame
|
52
|
+
void Update () {
|
53
|
+
|
54
|
+
if (!isTriggeredcp1) {
|
55
|
+
// sg って見て何かすぐにわかりますか?
|
56
|
+
p.transform.Find("sg") = sMarker;
|
57
|
+
p.transform.Find("sg1") = eMarker;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (!isTriggeredpy) {
|
61
|
+
Instantiate(e2,Vector3(position),Quaternion.identity);
|
62
|
+
Instantiate(e,Vector3(position),Quaternion.identity);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
```
|