|
HI, folks! Ive got problem with distance measurement between two screen positions (Vector2) - joysticks boundary is rectangle like, but it should be like cycle (i thought using distance variable as radius and it would provide cycle like boundary). PS. this script is based on Penelope tutorial Joystick script Thanks in advance!
(comments are locked)
|
|
What you need is Vector2.ClampMagnitude. If you clamp the two axis seperated it will always be a rectangle ;)
(comments are locked)
|
|
Ah, given you're picture the problem is clearer - your gui boundary is smaller than you're moveDistance. You need to clip an area inside the rectangle - so the guiboundary needs to be at least moveDistance on its shortest side. Bunny83's answer is the way to code it, once you've checked that the touch is inside the rectangle (otherwise it will move the joystick for a touch anywhere, presumably not what you want).
(comments are locked)
|

That code will position the joystick within a circle of radius moveDistance, so it is not clear what problem you are having.
The problem is that it doesnt somehow!
https://docs.google.com/drawings/d/1ZuzBMW8Nvpn35eVSXNd-T9RVHyMcUjmtvONb0sLgBOc/edit?hl=en_US
problem is showed graphicaly