質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -123,3 +123,117 @@
|
|
123
123
|
|
124
124
|
|
125
125
|
回答よろしくお願いします。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
追記:
|
132
|
+
|
133
|
+
以下がうまくいったコードです。
|
134
|
+
|
135
|
+
```C#
|
136
|
+
|
137
|
+
public class CameraController : MonoBehaviour {
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
[SerializeField]
|
142
|
+
|
143
|
+
private float RotSpeed;
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
private Vector3 last;
|
148
|
+
|
149
|
+
private Vector3 delta;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
// Use this for initialization
|
156
|
+
|
157
|
+
void Start () {
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
// Update is called once per frame
|
166
|
+
|
167
|
+
void Update () {
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
if (Input.GetMouseButtonDown(0))
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
last = Input.mousePosition;
|
178
|
+
|
179
|
+
}else if (Input.GetMouseButton(0))
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
delta = Input.mousePosition - last;
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
var preEA = transform.localEulerAngles;
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
preEA += new Vector3(-delta.y * RotSpeed, delta.x * RotSpeed, 0);
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
if (preEA.x > 75 && preEA.x < 285)
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
if (delta.y > 0)
|
200
|
+
|
201
|
+
{
|
202
|
+
|
203
|
+
preEA.x = 285;
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
else if(delta.y<0)
|
208
|
+
|
209
|
+
{
|
210
|
+
|
211
|
+
preEA.x = 75;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
transform.localEulerAngles = preEA;
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
last = Input.mousePosition;
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
```
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
if (preEA.x > 74.9f&&
|
67
|
+
if (preEA.x > 74.9f&&preEA.x<75.1f)
|
68
68
|
|
69
69
|
{
|
70
70
|
|