Best way to have a virtual joystick "Follow" the player touch using UI elements?

Hello!

In the past I did this before 5.2 a different way – without using the UI. I’d like to only use the UI for these things now.

I have the virtual “Joystick” below. The large circle is a button, and the small is the “stick” that I’d like to follow the players finger around.

I figure I can do a “Pointer Down” and “Pointer Up” event on the button to start and stop the joystick following, but I’m unsure of a few things:

1) What’s the best method of knowing which finger is down? Again, in the past, I’d do this differently, via code, and I’d use the touch code I had been using before. Is there a new method of knowing the finger number or what not? I figured this one out. Just calling the phase began on the touches gets the info, like before. Works well it looks like

2) What’s the best method of getting the finger position? I’ll need to know the position in screen space, and convert that to the position that the UI element needs to be at, correct? Well, damn. Looks like transform.position works for UI elements. Who knew. In screen space. So all this time I was looking for something complicated, when transform.position = Input.mousePosition etc would work. Crazy world.

3) What may be a good method of keeping the joystick from going beyond the boundaries of the larger circle?

Thanks!!!

2337104--157979--Screen Shot 2015-10-13 at 1.46.51 AM.png

Maybe you already saw it but if not, this video can help you.
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/space-shooter-to-mobile?playlist=17147

Thanks I"ll check it out, I haven’t seen it yet :slight_smile:

Also I’ve found this, im trying to implement it in a different way… but look useful:

Im trying to make a player that follow my finger at the same speed… like for a shoot’em up game where you move the ship with the finger al the time…