teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2018/03/22 07:33

投稿

退会済みユーザー
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

アニメーションするように変更

2018/03/22 07:33

投稿

退会済みユーザー
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
- mainCamera.transform.Translate ((start - end).x * Time.deltaTime, 0f, 0f);
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
  ```