Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions #1

Open
LarsDu opened this issue Feb 10, 2021 · 1 comment
Open

Suggestions #1

LarsDu opened this issue Feb 10, 2021 · 1 comment

Comments

@LarsDu
Copy link

LarsDu commented Feb 10, 2021

I actually started using GunsAndBullets1 for a project of mine, and after examining it closely, I had a few suggestions for both that class and this one (I gradually wrote my own version which differs quite substantially from this one).

  • There is no need to ever call the Update() function in this class. Using coroutines makes it much easier to implement things like burst fire. Automatic fire with coroutines is a bit trickier, but ultimately coroutines are much more flexible since they are only ever triggered when the player fires.
  • The use of the Queue for cycling through barrels is a bit excessive and leads to a bit of garbage collection. I actually found that this breaks on certain android builds for some reason. A simple index and modulo operation is all that is needed (ie:
                Transform barrel = barrels[currentBarrelIndex];
                SpawnAndFireBulletFromBarrel(barrel);
                currentBarrelIndex = (currentBarrelIndex + 1) % barrels.Length;
@brihernandez
Copy link
Owner

brihernandez commented Apr 12, 2021

I removed the use of queues when I did the barrel update. It's all done with indices and mod now.

I won't switch to using Coroutines though, because I think they're more trouble than they're worth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants