# Instantiate object by the rotation of current transform

I am trying to Instantiate a prefab onto the scene setting the rotation by the transforms rotation. Here is a snippet of code where I am stuck on:

``````var angle : float = -15.0; // or if I set this to 0.0 (read more to understand)
for ( var i : int = 0; i < 3; i++ )
{
transform.RotateAround(transform.position, Vector3.up, angle);
Debug.Log(angle);
angle += 15.0;
}
``````

I am trying to make a gun shoot bullets like a ‘burst’ effect.

If I set the angle variable to -15.0 and run the editor, and shoot the gun to make the bullets appear, then pause the editor, 2 of the 3 bullets have a rotation of 345.0 while the other has a rotation of 0.0.

If I set the angle variable to 0.0, run and pause the editor when the bullets appear, the first 2 bullets have the correct rotation of 0.0 and 15.0. But the third bullet has a rotation of 45.0?

WHAT I am doing wrong here? Thanks in advance!

It’s simple: RotateAround adds the variable angle to the current rotation, but you add 15 to angle before rotating again. If you start with -15, the object is rotated -15, 0 and 15 - thus the angle around Y will be -15, -15 and 0. If you start at 0, the object is rotated 0, 15 and 30 degrees, and the angles around Y will be 0, 15 and 45.

Just start with angle = 15; and remove the line angle += 15.0;.