I’ve started working on a top down shooter game, which is going to have several weapons to pick from during combat. I’ve got my pistol to feel pretty good, and my shotgun is too. The only problem is, I think I can make it run more efficiently.
This is the shotgun in action. It runs good, but initially had a little trouble creating the three bullets and then having them all fly different directions. I just wanted to get it working, so to make it work, I just made two more bullets.
I figured that this should work fine for the time being, but now that I’m focusing more on combat, I want to add two more bullets to add a better spread to it. To add on top of this, I have to write code for collision with all of these extra bullets as well. Is there a way to create bullets like how I’ve done for my shotgun, but only use one bullet instead of three different instances? My code is below. Weapon one is my pistol, weapon two is my shotgun.