Quantcast
Channel: Questions in topic: "moveto"
Viewing all articles
Browse latest Browse all 116

Mathf to get point on edge of circle (via radius and angle)

$
0
0
Hi guys, I am trying to create a GUI wheel with power-ups icons and having some trouble. I researched this quite a bit, and what I want it to do is put one gui element an equidistant space from the center of a circle area (thus creating a "power wheel"). However they are appearing unevenly spaced. I checked with some Debugs and it seems like the 360 degree circle is being split evenly according to the number of elements. Can you guys take a look at the code and point probable cause out? Thanks! Debug.Log(angle); rad = Screen.height * .00017f; for(int i = 0; i < powerL.Length; i++){ //Debug.Log(angle); tweenObject[i] = (GameObject)Instantiate(Resources.Load("3dText")); tweenObject[i].transform.name = powerL[i]; tweenObject[i].transform.parent = spawnPoint.transform; tweenObject[i].transform.position = new Vector3(.15f,.4f,.01f); float X = tweenObject[i].transform.position.x + rad * Mathf.Cos(angle); float Y = tweenObject[i].transform.position.y + rad * Mathf.Sin(angle); Vector3 finalPos = new Vector3(X,Y, 0); //Vector2 finalPos = new Vector3(X,Y, 16.2785f); iTween.MoveTo(tweenObject[i].gameObject,finalPos, .5f); angle = angle + (360 / powerL.Length); Debug.Log(angle); }

Viewing all articles
Browse latest Browse all 116

Trending Articles



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