Make bullets follow player?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
teilzeit
Prole
Posts: 2
Joined: Fri Nov 11, 2022 1:14 pm

Make bullets follow player?

Post 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.
KalevTait
Prole
Posts: 7
Joined: Sun Aug 19, 2018 10:28 am

Re: Make bullets follow player?

Post 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.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Make bullets follow player?

Post 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.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Make bullets follow player?

Post by darkfrei »

Maybe change the countdown based on player speed or add the player speed to all bullets?
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
teilzeit
Prole
Posts: 2
Joined: Fri Nov 11, 2022 1:14 pm

Re: Make bullets follow player?

Post 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.
User avatar
fridays18
Citizen
Posts: 90
Joined: Tue Nov 01, 2022 3:24 pm

Re: Make bullets follow player?

Post 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
KalevTait
Prole
Posts: 7
Joined: Sun Aug 19, 2018 10:28 am

Re: Make bullets follow player?

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest