Bullet arc problem

hello guys i need help
i need to create a arc of bullets but i can never center the object correctly as you can see from the attached gif
i need to create a 3-4-5 arc and another 360° arc that hits in every direction
can someone help me please?
I know there is an advanced bullet extension but I would like not to use it
ezgif.com-video-to-gif-converter

I suppose you could calculate the angle of the first bullet based on the total number of bullets to be fired and the angle of spread.

Say, if you’re firing 4 bullets at 20 degrees apart,
you multiply then divide by 2 to get the initial angle:
(4*20)/2 = 40
This result would still be offset so you
subtract half of the spread value. (20/2=10) *edit: i tend to miss this part. heh
40 -10=30

Then you subtract that from the target angle.
If your reference object is rotated towards, let’s say 10 degrees:
that would be 10 - 30 = -20
So there you have the initial angle for your first bullet.
You then add 20 for each succeeding bullet.
Hence:
Bullet1 = -20 ; bullet2 = 0 ; bullet3 = 20 ; bullet4 = 40

Although if the number of bullets and angle difference doesn’t vary too much, I kind of prefer to do this manually. Like if I want the object to shoot 5 bullets, I’d have an event which has 5 sub-events, one for each bullet where I’d manually assign their own angles. I admit it’s pretty crude though. But if it’s a lot more bullets, yeah, that’s the math I’d do above.

1 Like

If you want to always shoot NOT EVEN number of bullets so 1 > 3 > 5 > 7 > 9
Instead of 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9

Then change this to 2

Or you can go with static numbers if you want

1 Like

thanks @Levio for the detailed explanation, now everything is clearer on how to proceed.
what you suggested @ZeroX4 is exactly what I need
I think I will follow your suggestion
thanks a lot for the help to both of you

2 Likes

sorry if I come back to this topic again…
could you tell me why using an object variable doesn’t work for me? while if I use a scene variable it works correctly as in the example sent by @ZeroX4
I have multiple enemies in the game and each one has a different spread and number of projectiles created so I thought of using an object variable for each enemy

If so then you need to use for each object event type

Right click any event and choose ADD then for each object or something like that

do you think this is correct? it seems to work this way but don’t you think it’s better to give a variable object to enemies?

Holy F
IDK how it was not clear

For each event type
Was needed so each object work independently

So you added it exactly to be able to use object vars instead of scene vars

YET if it works i see no reason to mess with it

Like look if it works and you change ANYTHING and it will stil work
Then what was the point?
Golden life rule
DO NOT fix something that is working
But choice is yours

You didn’t explain where the for each object had to go.


@ilary27, put the for-each enemy like this:

No matter where it needed to go

Question was why it works with scene vars but not object vars
And i did answer it requires for each object event type

And Ilary27 added it but did not use object vars

Just to be perfectly clear i do get your point
My point is
He show screenshot using scene vars not object vars

Actually i look at it now it is mixed scene and object vars
I just looked at vars in events with compare two numbers

what I meant was that using scene variables creates the arc while if I use an object variable all the bullets are directed towards the same angle.
I tried to add the for each enemy as suggested but it still didn’t work even if there was only one enemy.
that’s why I tried to find a solution with scene variables.
I was just wondering why it worked with scene variables and not with object variables.
this is what happens when using the object variable with or without for each enemy
gggg

We are aware what you meant
YET look what MrMen suggested

I did see you have spread and spread offset as scene var so it would be same for every object
While MrMen did notice you used object vars
And we were simply looking at different screenshots

MrMen was looking at this

I was looking at this (your next message below it)

And what MrMen wrote is 100% accurate and will fix your issue

What FOR EACH OBJECT does is like telling your game
Let each object have independent based on some factor even so all of objects have same factor just with different value

FOR EXAMPLE
Imagine you have HP var i mean all your enemy have HP variable
You check if variable HP of enemy is below 50 if so you change opacity of enemy to 100 (max is 255)

And so one enemy having hp below 50 would cause all of them to change opacity to 100

IF you would use it inside for each object event then ONLY ones with value of HP variable below 50 would have their opacity changed to 100
While all with HP above 50 would be unchanged

And same story here
You want to shove in your logic under for each object
So each enemy can ACT independent from other enemies based on value of his variables

1 Like

I managed to solve the problem by finding a typo.
thanks again guys and sorry

1 Like