Quantcast
Viewing latest article 4
Browse Latest Browse All 8

GUI Joy Stick move along arc?

Original Question:I want to move my GUI joy stick in a perfect circle, not exceeding defined distance. Here is my code so far, that obviously doesn't work. How can I modify this to rotate the joy stick position along an arc of defined distance? Updated Question: I have updated my code to where the joy stick moves around a circle. However I would like to achieve the same outcome with less code. var joyStick:Texture; //defined in inspector var joyRect:Rect; //defined in inspector var maxDist:float; //defined in inspector private var joyCenter:Vector2; function Start(){ joyCenter = joyRect.center; } function OnGUI(){ var event:Event = Event.current; if(Input.GetKey(KeyCode.Mouse0)){ var mousePos:Vector2 = event.mousePosition; var horDist:float = Mathf.Pow(mousePos.x-joyCenter.x, 2); var vertDist:float = Mathf.Pow(mousePos.y-joyCenter.y, 2); var dist:float = Mathf.Sqrt(horDist+vertDist); if(dist

Viewing latest article 4
Browse Latest Browse All 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>