回答編集履歴
2
修正
answer
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
public class Swipe : MonoBehaviour {
|
8
8
|
public Vector3 start;
|
9
9
|
public Vector3 end;
|
10
|
-
public float deltaX;
|
10
|
+
public float deltaX = 0f;
|
11
11
|
public Camera mainCamera;
|
12
12
|
|
13
13
|
void Update () {
|
1
アニメーションするように変更
answer
CHANGED
@@ -7,18 +7,19 @@
|
|
7
7
|
public class Swipe : MonoBehaviour {
|
8
8
|
public Vector3 start;
|
9
9
|
public Vector3 end;
|
10
|
-
|
10
|
+
public float deltaX;
|
11
11
|
public Camera mainCamera;
|
12
12
|
|
13
13
|
void Update () {
|
14
|
-
|
15
14
|
if (Input.GetMouseButtonDown (0)) {
|
16
15
|
start = Input.mousePosition;
|
17
16
|
}
|
18
17
|
if (Input.GetMouseButtonUp (0)) {
|
19
18
|
end = Input.mousePosition;
|
20
|
-
|
19
|
+
deltaX = (start - end).x;
|
21
20
|
}
|
21
|
+
mainCamera.transform.Translate (deltaX * Time.deltaTime, 0f, 0f);
|
22
|
+
deltaX *= 0.9f;
|
22
23
|
}
|
23
24
|
}
|
24
25
|
```
|