[Solved] Contra-Style Spread Gun

Hello everybody.
In my game, there is an item that gives the player a chance to shoot a fan of 5 bullets at once, similarly to the Spread Gun from Contra. I tried to make something like this, but it just doesn’t seem to work. Does anybody know how to make a Contra-style Spread Gun in the most optimized way possible? Thanks in advance.

hi, post your code to see what do you do wrong
It occurs to me that you could do a repeat loop and shot 5 bullets, is that what you want?

Here it is (look under the HASSPREADBULLETS tab).


So far, that is the best I can do, just making all 5 bullets shoot in a random fan. Is it possible to make each individual bullet travel in it’s own specific direction, even if the “repeat” event is used? Or will this require more code? Or should I just stick with what I have?
(Note: I have the bullet spawning the spread bullets, which are called “ExtraBullets”. Should this be changed? If so, then how?)

hi
What i understand from your code is that yo do 5 times
create extrabullet and for each bullet in the game add a permanent force with random angle to the created extrabullet.
Is that what you want to do?!
Maybe you could explain the behaviour to see if the code is correct.

Technically, no. I would like each individual bullet to fly in a specific direction, such as bullet 1 to fly at 170 degrees, bullet 2 to fly at 175 degrees, and etc.

1 Like

Maybe a good way achieve that is using custom points in sprite itself like in this example


And try from there to specify the angle of the individual bullets

i think it is possible, could you share your project(remove anything not necessary if you want) and i’ll try to fix it.
It is hard to tell when you can’t see what you are doing :wink:

Hello, sorry for the late reply. I changed the point where the bullets are created to the character instead of the bullets. Here is the new code (Under HASSPREADBULLETS again):


It works good right now. So now how do I have each bullet travel in it’s own individual direction? Thanks in advance.

1 Like

So this is my way for sure maybe a more good way exist but this is how i would do it with my knowledge so far.


Make sure the origin and pivot of the bullet is also on the center of the sprite
20190714_135935
Edit: I have the point in the player sprite too if you want to have different guns with different sizes I think for simplicity is a good option to keep the points in player sprite instead to the gun itself and play just with the position of the points

And this is an update with more clean actions and fire rate

It worked! Thanks mate! :smiley:

2 Likes