Multidirectional shooting

I’m wanted to try making an enemy/boss objects that shoots in multiple directions like how you see those types of enemies in bullet hell games.
here is an image for reference

the red lines is where the bullets are supposed to come from and the circles at the end of each line is the bullet point.

I that the fire bullet extension is a thing with the multishot option but I dont think that the multishot function is going to solve it

1 Like

You cannot fire 1 bullet and expect it split into 8
You need to fire 8 bullets in 8 different directions

LMB to fire

1 Like

Do you mind explaining the long string when the bullet is created? I want to understand and not blindly copy codes

1 Like

If you look at it there is kinda nothing cryptic there

Only difference between 2 strings are X and Y (because one is for X pos and other is for Y obviously)

Player.CenterX()+XFromAngleAndDistance(Player.Angle()+AngleOffset,20)
Player.CenterY()+YFromAngleAndDistance(Player.Angle()+AngleOffset,20)

See copy paste just X and Y is only difference

I will go on just explaining X cause its exactly same for Y
So we need to create bullet somewhere
As our base we use

Player.CenterX()

But that would create it in center of player we need to add some offset position to it
And we do not want JUST left or right we want some angle offset in 360° plane so we use

Player.CenterX() + 

XFromAngleAndDistance(Player.Angle()+AngleOffset,20)

So we are telling game to create bullet at Player.CenterX() + some position calculated from angle and distance
And formula goes Player Angle + Variable ← to calculate what angle offset we want and with 20 pixels distance from Player.CenterX()

When you click LMB you set AngleOffset variable to 0 so its always starts from 0
image

You repeat this BS 8 times so i used calculator to divide 360 by 8 which is 45
That is why i am adding 45 to variable

So at first variable is 0 then its 45 then its 90 and so go on up to 360
Since we establish that bullet will be spawned from center of player + 20 pixels distance in some offset position of angle which is calculated from AngleOffset variable now you get how this variable with each repeat changes

And then i am pushing bullets with permanent force toward some angle
Where formula is

Bullet.AngleToObject(Player)-180

Simply angle from bullet to player but i -180 cause if not then bullets would go to player and not from player

Actually more sense would be

Player.AngleToObject(Bullet)

But on other hand its same as how far i am from you vs how far you are from me

Distance (value) will be the same just my pos and your pos will switch which is 1st in equation
Where again end result will be the same

So just to sum up

Player.CenterX()+XFromAngleAndDistance(Player.Angle()+AngleOffset,20)

Initial X position + ( Calculate X from angle and distance + AngleOffset variable )

Same for Y
Player.AngleToObject(Bullet)

Angle from one object to another object
1 Like

I see I see, I’ll have to mess around with the angleoffset values and see what results I’ll want.

Also, I want to ask is if the object is rotating, would the angles rotate with it aswell? because earlier I was messing around with the fire bullet extension and the simple add permanent force to object while the object they spawned from is rotating an the results were that the spawn points were not rotating with the object and they were just shot from a stable angle.
My goal is for the spawn point to rotate along with the object when it itself is rotating to give that wave of bullets like you see in bullet hell games

Yes it will

And if you NOT want it to rotate with object then instead of

Player.CenterX()+XFromAngleAndDistance(Player.Angle()+AngleOffset,20)

Use

Player.CenterX()+XFromAngleAndDistance(AngleOffset,20)
Same for Y

WHERE (you want bullets to rotate i mean their spawn point)
NOTHING is stopping you in adding another variable

Player.CenterX()+XFromAngleAndDistance(AngleOffset,20)

This will create bullets no matter what player angle is BUT THIS

Player.CenterX()+XFromAngleAndDistance( AngleOffset + AnotherVariable , 20 )

You could simply increase value of AnotherVariable each after each repeat for each
For example here
image

Here add change the variable AnotherVariable ADD 5
And even so player is in same angle
Bullets will create on like spinning pattern
Well F me

Let’s check it out
Player spins so does spawn points

Player does not spin yet spawn points does

Now you can manipulate AnotherVariable to spin the hell out of it (btw reverse direction would be subtract from AnotherVariable instead of add)

Did you try it? I’m pretty sure this is exactly what multishot is meant to do.

1 Like

@bluestahli11 Magicsofa is 100% right here
I am not using fire bullet and i totally forgot it does have multishot feature

Howerver you still would need some var to offset rotation if it should not be based on angle
So you can combine firebullet multishot with what i explained to you with using forces to fire bullet

Yeah, I tried the multishot function and its working, I just haven’t fiddled with it enough yesterday, also I have a question about it and degrees, if I set the multishot to 4 and the degrees to 360, what degrees should I set it to so that the first and last bullet dont stack ontop of eachother?

Calculator is your best friend here
I don’t know answer but i know how to find it

1st thing i would try is 360 - 360/4 soo
360 / 4 = 90 and 360 - 90 = 270

So instead of 360 i would try putting there 270
IDk if that is correct
I just have ideas how to try and find such values
My idea here is
Because it overlap then its taking 1 space to much so without deleting bullet let’s go 1 space less
MAYBE correct formula is 360 / how many bullets you wanna fire + 1
Then subtract that value
So 360 / 5 (because you want to fire 4 bullets) = 72
360 - 72 = 288
So maybe its 288 instead of 360