Problem with Trigonometry

Hello, how are you?

I have an issue with this code and I am stuck with it:

This is a code piece that I used to use back in the game maker days. But in unity doesn’t quite respond in the same way.

for (int i = 1; i<=360; i+=120) {

                                GameObject option = (GameObject)Instantiate (circular);
                                float xD = (Mathf.Cos (i));
                                float yD = (Mathf.Sin (i));

                                Vector3 pos = new Vector3 (transform.position.x + len * xD, transform.position.y + len * yD, 0);
                                option.transform.position = pos;
                                option.transform.parent = transform;
                                abec.Add (option);

                        }

I expected to have 3 equidistant option around my transform. But instead the 3 of them appear in the upper part.

Any help?

Thank you!

Aren’t you looking for arc sine/cosine? Also, those functions us radians, not degrees.

Not really, I am looking for the coordinate given by x=x+lengthcosine(iterator) / y=y+lengthsine(iterator) so for 360 degrees / 3 would set one option at 1º, 120º and 240º…

I tried multiplying for radtodeg but keeps mostly the same…

am I doing something wrong at: ??

float xD = Mathf.Cos (i)*Mathf.Rad2Deg;
                                float yD = Mathf.Sin (i)*Mathf.Rad2Deg;
                                Vector3 pos = new Vector3 (transform.position.x + len * xD, transform.position.y + len * yD, 0);

sorted.

                                float xD = Mathf.Cos ((float)i * Mathf.Deg2Rad);
                                float yD = Mathf.Sin ((float)i * Mathf.Deg2Rad);

                                print (xD + "  " + yD);

                                Vector3 pos = new Vector3 (transform.position.x + len * xD / 100, transform.position.y + len * yD / 100, 0);

Had to be given in radians. Remember kids! give them radians