Basically, the player drags (with their touch input) the outer circle. The arrow “rotates” accordingly. They rotate around the pivot in the center. How do I accomplish this. There are SO many rotation functions in Unity and its quite overwhelming. Things like:
Transform.Rotate
Quaternion.Euler
Quaternion.eulerAngles
Transform.localEulerAngles
Mathf.LerpAngles
etc etc.
I really don’t know where to start on this one. Have not had to use rotations up to this point in my game programming.
Thanks much,
Mark
The answer to this will depend on whether you are doing this with the GUI or with an object in the game. For a GameObject, you need to get the position of the touch in the game world using Camera.ScreenToWorldPoint or a raycast. You can then use transform.LookAt to rotate the object to face the target point (this is straightforward if you design the object so that its anchor point is at the centre of rotation).
With the GUI, you will need to subtract the object’s centre point coordinate from the touch position. You can then make a rotation from this, using Quaternion.LookRotation and use it to rotate the GUI matrix with the Matrix4x4.TRS function:-
var direction = touch.position - centrePoint;
var rot = Quaternion.LookRotation(direction);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, rot, Vector3.one);
(In practice you will most likely have to do a bit more than this depending on the exact effect you want, but it should give you an idea.)