Constant 2D Bullet movement in a shmup

I've been following the pixelnest tutorial to make a 2D shmup (http://pixelnest.io/tutorials/2d-game-unity/player-and-enemies/).

While working on this I've experimented with increasing the firing rate to get a continuous stream of bullets, and I've noticed that bullets are more spaced apart if the ship is moved backwards, and they get clumped up when the ship is moved forwards. Is there a way to maintain constant distance between bullets no matter the movement of the player?

Should I even care? I get the feeling that if the player moves backwards then the firing rate is essentially slower (at least until they reach the edge of the screen) and vice versa if you move forwards.

It is classical Doppler effect, which is quite normal thing. If you move backwards, then the distance between bullets is normal_distance_caused_by_firerate - ship_backward_distance_passed, instaead of just normal_distance_caused_by_firerate if ship stands still.

If you increase the bullets speed, then this effect would be harder to notice, because the distance would be bigger by itself, compared to the ship speed.

You could increase the firerate if ship's moving back, and decrease it when it's moving forward, but this isn't normal behavior, and it could look weird. It would be also cheating on game logic.

To sum up, you should leave it as it is, or decrease ship speed / increase bullet speed to decrease the visual difference in distance between bullets while moving forward/backward.

• +1 for the Doppler effect. As kreys mentions this is absolutely normal behavior and something most people feel is a natural response. Apr 24, 2014 at 11:00
• Hah, I've read about the Doppler effect but it never crossed my mind it would apply here! As for 'natural response', I was more concerned if this would affect the gameplay balance in anyway. It does sorta makes an interesting minor risk/reward mechanic (get closer to enemies to kill them faster). Other shmups (touhou, treasure shmups, etc) appear to have achieved constant bullet distance but it could very well be that they made bullet velocities to be so high that I'm fooled into thinking the distance between shots stays even. Apr 24, 2014 at 14:43
• You don't actually kill the enemy much faster. I think you are still confused? The only difference in killing effectiveness is the "latency" of the bullets (time it takes a bullet to travel) as the bandwidth (fire-rate) is the same. So basically if you are closer it will die faster only because bullets travel a shorter distance which takes less time. Apr 24, 2014 at 16:03
• Well let's say that if I were to include a laser weapon, that weapon would have pretty much no travel time (relative to a bullet-based weapon) and so deal constant damage to the target regardless of how the player moved. My question was essentially about making a bullet-based weapon act like a laser, since if the player moved backwards/forwards then the bullet travel time would increase/decrease. Apr 24, 2014 at 16:48
• @MHTri Your ability to exploit the doppler effect is naturally limited by the distance remaining between you and the target. Eventually you'll have to retreat, and during that time your effective rate of fire (from the point of view of the targets) is decreased. The faster you move, the higher the rate of fire, but the sooner you'll run out of space. That doesn't mean a smart player can't take advantage of it - if you can kill the enemy before you run out of space, and retreat when there's no enemies, it's a net win. But I'd argue smart play should be rewarded, not punished. Apr 24, 2014 at 16:49

Add the ship's velocity to the bullet velocity when they are created.

When moving backwards, the bullets will be slowed down. When moving forward, they'll be sped up. However this will have the effect of making the bullets move horizontally when the ship does - experiment with having the bullets be affected by only the y-velocity.

• Ironically, while this is closer to real physics and avoids the "problem" the question author is trying to avoid, the result isn't what I'd expect as a player. As @kreys says, the Doppler effect is what people expect to see here. Apr 24, 2014 at 14:12
• if you do such, you can find yourself in weird situations, for example when you shoot two bullets quickly, meanwhile changing ship movement direction from backward to forward you would have bullets with different speed, where one can catch up the other, which is totally unnatural. Apr 24, 2014 at 14:13
• (Then again, it's only closer to the real physics if there's no air resistance. And to be really accurate you'd also subtract the bullets' momentum from the ship's. But that would be silly.) Apr 24, 2014 at 14:14
• Thanks for this. I'm going to give it a try tonight and see what happens, but I imagine this is a case of premature optimization and the variable bullet spacing will have a negligible gameplay effect. Apr 24, 2014 at 14:45
• I'd agree that you don't really need to care about this one. I know I don't when I play SHMUPs Apr 24, 2014 at 14:54