# Rotating bullets away at a constant speed.

Hello!

I’ve been working on a script to quickly create bullet patterns, however, I’ve noticed that when I rotate the bullets away from origin, the further away they rotate from it, the quicker they rotate around it. Is there a way to make it so that I can rotate a bullet at a constant speed, no matter how far it is?

Here is the script:

``````    void Update () {

GetComponent<Rigidbody2D>().velocity = transform.up * bulSpe;

transform.RotateAround(Vector3.zero, Vector3.forward, traRot * Time.deltaTime);

}
``````

The length of an arc over a certain angle depends on the radius of the arc, so it makes sense that that would happen.

The pattern you’re going for is unclear. Do you want:

-Circular motion, when the projectile just moves in a circle of constant radius and fixed center?
-A spiral, where the projectile moves in a circle of changing radius and fixed center?
-A corkscrew, where the projectile travels around a moving center?

Sorry for not being clear enough, I am trying to achieve a spiral pattern, very typical in bullet hell games.
Here is a video to further clarify what I’m trying to achieve.

I didn’t quite see any rotating bullets in there, just a lot of bullets fired in succession while sweeping through firing angles. All of the bullets are travelling in a straight line.

You should be able to get this effect just by telling the bullet to move forward each frame. Then, right after each bullet is placed (use pooling for this), just rotate it to the correct angle. You can probably write a short coroutine that waits a set amount of time, places a bullet, sets its rotation based on a simple angle variable, then increments the angle for the next bullet. You could do this inside of a for loop to simplify the angle sweep and easily set the number of bullets.

1 Like

Yes! Now I see I was looking at it in the wrong way, I was over-complicating thing by trying to rotate the bullet while it was in the air, when in reality they never “Curve” just go forward and what actually changes is the angle at which bullets are being fired!

1 Like