# Rotate Triangles "Correctly" Around The Circle

Hello,

I have a circle and this circle has orbits around it. The orbits’ shape is triangle.

My orbit creation code:

``````public void CreateOrbitsAroundCircle(int num, Vector3 point, float radius)
{

for (int i = 0; i < num; i++)
{

/* Distance around the circle */
var radians = 2 * Mathf.PI / num * i;

/* Get the vector direction */

var spawnDir = new Vector3(horizontal, vertical, 0);

/* Get the spawn position */
var spawnPos = point + spawnDir * radius; // Radius is just the distance away from the point

/* Now spawn */
var newOrbit = Instantiate(orbit, spawnPos, Quaternion.identity, this.transform);

//newOrbit.name = playerName;

/* Rotate the enemy to face towards player */
//enemy.transform.LookAt(point);

//enemy.transform.Translate(new Vector3(0, enemy.transform.localScale.y / 2, 0));
}
}
``````

I can add orbits by this code up to 10 orbits.

My question is this: I want to rotate triangles like my circle has spikes!
Like this:

How can I do that?

First make sure your triangle prefab is pointing up. This will make it easy to calculate the rotation to apply to the triangle if we already know the rotation of the prefab before we spawn it. Then you just need to calculate the angle to rotate your triangle by depending on where on the circle you are going to place it. You can do that by calculating the angle between the up direction and the direction of your spawn position.

``````var spawnPos = point + spawnDir * radius; // Radius is just the distance away from the point

float rotAngle = Vector3.Angle(Vector3.Up, spawnDir);
if(spawnDir.x < 0) rotAngle *= -1;
Quaternion orbitRotation = Quaternion.Euler(0, 0, rotAngle);
/* Now spawn */
var newOrbit = Instantiate (orbit, spawnPos, orbitRotation, this.transform);
``````

I just added this code to orbits. It worked well!

``````target = transform.parent.gameObject;
Vector3 dir = target.transform.position - transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle + 90, Vector3.forward);
``````