質問編集履歴
2
テンプレートを参考に更新させていただきました。ご検討よろしくお願いいたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,191 @@
|
|
1
|
+
### 前提・実現したいこと
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
UnityでPhotonを使用しているのですが、Line Rendererを通信している相手側にも同期させたいのですが、皆目検討がつきません。情報を知っている方がいたらご教授いただけると助かります。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
### 該当のソースコード
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```using System.Collections;
|
26
|
+
|
27
|
+
using System.Collections.Generic;
|
28
|
+
|
29
|
+
using UnityEngine;
|
30
|
+
|
31
|
+
using UnityEngine.UI;
|
32
|
+
|
33
|
+
//using UnityEngine.SceneManagement;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
public class testLine : MonoBehaviour {
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
private LineRenderer lineRenderer; //LineRendererを入れているオブジェクトのデータ管理
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
int i;
|
46
|
+
|
47
|
+
int count=0;
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
void Start () {
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
// Update is called once per frame
|
60
|
+
|
61
|
+
void Update () {
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
LineRenderer renderer = gameObject.GetComponent<LineRenderer>();
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
// 線の幅
|
72
|
+
|
73
|
+
renderer.SetWidth(0.1f, 0.1f);
|
74
|
+
|
75
|
+
// 頂点の数
|
76
|
+
|
77
|
+
renderer.SetVertexCount(3);
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
renderer.SetPosition(0,new Vector3(0f,0f, -1f));
|
82
|
+
|
83
|
+
renderer.SetPosition(1, new Vector3(0f,10f, -1f));//x横y縦
|
84
|
+
|
85
|
+
renderer.SetPosition(2, new Vector3(2f,0f, -1f));
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
count += 1;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
public void RpcDrawLines(GameObject start, Vector3 end, bool isOn)
|
102
|
+
|
103
|
+
{ LineRenderer beam = start.GetComponent<LineRenderer> ();
|
104
|
+
|
105
|
+
if (isOn)
|
106
|
+
|
107
|
+
{ beam.SetVertexCount (2);
|
108
|
+
|
109
|
+
//beam.material = BeamMaterial;
|
110
|
+
|
111
|
+
beam.SetWidth (0.07f, 0.07f);
|
112
|
+
|
113
|
+
beam.enabled = true; beam.SetPosition (0, start.transform.position);
|
114
|
+
|
115
|
+
beam.SetPosition (1, end); } else { beam.enabled = false;
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
public bool isBeam = false;
|
126
|
+
|
127
|
+
//isBeam = true; // set this to false when you want to disable the beam
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
public void OnBeamActive(bool isOn) //buttenを押す等のアクション時に反応させる
|
136
|
+
|
137
|
+
{
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
LineRenderer renderer = gameObject.GetComponent<LineRenderer>();
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
// 線の幅
|
150
|
+
|
151
|
+
renderer.SetWidth(0.1f, 0.1f);
|
152
|
+
|
153
|
+
// 頂点の数
|
154
|
+
|
155
|
+
renderer.SetVertexCount(3);
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
renderer.SetPosition(0,new Vector3(1f,1f, -1f));
|
160
|
+
|
161
|
+
renderer.SetPosition(1, new Vector3(10f,10f, -1f));//x横y縦
|
162
|
+
|
163
|
+
renderer.SetPosition(2, new Vector3(2f,-20f, -1f));
|
164
|
+
|
165
|
+
//targetは、ビーム/ラインの終点を参照するTransformです。あなたが望むようにそれを初期化する
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
### 試したこと
|
180
|
+
|
181
|
+
https://translate.googleusercontent.com/translate_c?depth=1&hl=ja&prev=search&rurl=translate.google.co.jp&sl=en&sp=nmt4&u=https://gamedev.stackexchange.com/questions/131740/how-to-sync-a-linerenderer-in-a-multiplayer-game&usg=ALkJrhg7FGquSqt1Y4dx3ijKLl0p6mNZ4w
|
182
|
+
|
183
|
+
を参考にさせていただこうとしたのですが、知識も、経験も無くどう活用したらいいのかわかりません…>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
### 補足情報(FW/ツールのバージョンなど)
|
188
|
+
|
189
|
+
UnityのC#を使用しています。
|
190
|
+
|
191
|
+
ここにより詳細な情報を記載してください。
|
1
文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
UnityでPhotonを使用しているのですが、Line Rendererを通信している相手側にも同期させたいのですが、皆目検討がつきません。情報を知っている方がいたらご教授いただけると
|
1
|
+
UnityでPhotonを使用しているのですが、Line Rendererを通信している相手側にも同期させたいのですが、皆目検討がつきません。情報を知っている方がいたらご教授いただけると助かります。
|