Page 1 of 1
Make bullets follow player?
Posted: Fri Nov 11, 2022 1:28 pm
by teilzeit
Hi, I'm making a shmup game but I'm having an issue where bullets fired from the player don't stay in front of the player as the player moves. They'll cluster up if the player is moving forward and be too spaced out if the player is moving backwards. I've tried adding the velocity of the player to the velocity of the bullet every frame, but this creates another awkward effect where the bullets will seemingly move too fast or too slow depending on the player's movement. I was wondering if there's a proper way to fix this. Thanks.
Re: Make bullets follow player?
Posted: Sun Nov 13, 2022 6:52 pm
by KalevTait
The effect you are describing occurs in most commercial shmups, so I wouldn't worry about it if I were you.
But if you really want to worry about it, try adjusting the firing rate, so that you fire slower if moving forward and faster if you are moving backwards. There's probably some math you could use to work out exactly how much to adjust the rate of fire by, but I'd just eyeball it to get something that looks okay.
Re: Make bullets follow player?
Posted: Sun Nov 13, 2022 7:32 pm
by pgimeno
Raising the speed of the bullets might also help make the effect less noticeable. It's not something you can avoid, it's just a natural consequence of how the world works.
Re: Make bullets follow player?
Posted: Sun Nov 13, 2022 7:47 pm
by darkfrei
Maybe change the countdown based on player speed or add the player speed to all bullets?
Re: Make bullets follow player?
Posted: Wed Nov 16, 2022 12:34 pm
by teilzeit
Changing the speed and countdown seems to remedy the issue to an extent, but then I still have the problem of the player sort of "outrunning" their own projectiles which looks strange. I can add the player speed to each bullet but then there's some other strange effects, like bullets clearly appearing to move more slowly, or even backwards, if the player moves backwards.
Re: Make bullets follow player?
Posted: Wed Nov 16, 2022 4:15 pm
by fridays18
A method I use is making it so if they have an x below the player increase, x above decrease, y above decrease, y under increase, etc
Re: Make bullets follow player?
Posted: Thu Nov 17, 2022 1:20 am
by KalevTait
teilzeit wrote: ↑Wed Nov 16, 2022 12:34 pm
the problem of the player sort of "outrunning" their own projectiles
Every shmup I've seen, the bullets travel faster than the player is able to move. Bombs are slower, but outrunning bombs doesn't look weird.