# Rotating Object on Y Axis with Finger and applying Torque/Inertia

Discussion in 'Physics' started by g0tNoodles, Jul 11, 2018.

1. ### g0tNoodles

Joined:
Nov 28, 2010
Posts:
191
Hello,

I am trying to make a spinning wheel type game where the player can use their finger to rotate the wheel. The rotation follows the players movement in a full 360 degrees but this is where I start to have issues - it is based on the screen width/height which causes problems on different devices I am assuming.

The ideal gameplay would be:

Players touches the wheel,
Upon letting go, the wheel continues to spin with inertia, eventually coming to a stop

I have tried it on 3 different devices and get 3 very different results. Can anyone point me in the right direction to produce what is probably a much simpler implementation of the desired interaction?

This is what I currently have for following the finger:

Code (CSharp):
1. if (touch.position.x > Screen.width / 2)
2. {
3.      // Right
4.      if (f_lastX < Input.GetAxis("Mouse Y"))
5.      {
6.         i_direction = 1;
7.         transform.Rotate(Vector3.down, spinSpeed * Time.deltaTime);
8.      }
9.      if (f_lastX > Input.GetAxis("Mouse Y"))
10.      {
11.         i_direction = -1;
12.         transform.Rotate(Vector3.down, -spinSpeed * Time.deltaTime);
13.       }
14. }
15. else if (touch.position.x < Screen.width / 2)
16. {
17.      // Left
18.      if (f_lastX < Input.GetAxis("Mouse Y"))
19.      {
20.          i_direction = -1;
21.          transform.Rotate(Vector3.down, -spinSpeed * Time.deltaTime);
22.       }
23.       if (f_lastX > Input.GetAxis("Mouse Y"))
24.       {
25.          i_direction = 1;
26.          transform.Rotate(Vector3.down, spinSpeed * Time.deltaTime);
27.        }
28. }
29.        f_lastX = -pointerY;
30. }
Thanks!