質問編集履歴

1

指摘のため

2019/01/12 07:19

投稿

ITStudyman
ITStudyman

スコア15

test CHANGED
File without changes
test CHANGED
@@ -6,13 +6,99 @@
6
6
 
7
7
  ![イメージ説明](c23ea67abfce67184754eed599723b76.jpeg)
8
8
 
9
+
10
+
9
11
  ↓左側のオブジェクトは、dtimeblueが255を超えると移動するようになっています。
10
12
 
13
+ '================================================================
14
+
15
+ public class Item : MonoBehaviour {
16
+
17
+ public GameObject daytime; //Daytimeが入る変数
18
+
19
+
20
+
21
+ void Start()
22
+
23
+ {
24
+
25
+ daytime = GameObject.Find("weater");
26
+
27
+ }
28
+
29
+
30
+
11
- ![イメージ説明](44208ff935c57c3392de1848ef37850f.jpeg)
31
+ // Update is called once per frame
32
+
33
+ void Update()
34
+
35
+ {
36
+
37
+ float dtimeblue = daytime.GetComponent<DayTime>().blue;//DaytimeのBlue取得
38
+
39
+
40
+
41
+ if (dtimeblue == 255f)
42
+
43
+ {
44
+
45
+ Vector3 pos = this.transform.position; pos.x = -0.4f; pos.y = 0; this.transform.position = pos;//本体
46
+
47
+ }
48
+
49
+ // Debug.Log(pos.x);
50
+
51
+ }}
52
+
53
+ '================================================================
54
+
55
+
12
56
 
13
57
  ↓上のスクリプトのtransform.positionを取得して、常に横に並べて置けるようにしたいですが、できません。
14
58
 
59
+
60
+
61
+ '================================================================
62
+
63
+ public class Irem02 : MonoBehaviour
64
+
65
+ {
66
+
67
+ // Start is called before the first frame update
68
+
69
+ public GameObject item; //Itemが入る変数
70
+
71
+
72
+
73
+ void Start()
74
+
75
+ {
76
+
77
+ item = GameObject.Find("Item");
78
+
79
+ }
80
+
81
+
82
+
15
- ![イメージ説明](752b9764ed9b63fcd7f36359be882ceb.jpeg)
83
+ // Update is called once per frame
84
+
85
+ void Update()
86
+
87
+ {
88
+
89
+ //Vector3 itemp = item.transform.position;//Itemの座標取得
90
+
91
+
92
+
93
+ Vector3 itemp = item.transform.position;
94
+
95
+ itemp.x = 0; itemp.y = 0; item.transform.position = itemp;//本体
96
+
97
+ }}
98
+
99
+
100
+
101
+ '===================================================================
16
102
 
17
103
 
18
104