How to create spiraling bullets

I just tried what MrMen initially suggested:

and that works! One bullet is spawned and it travels in a spiral pattern. So @Shadowbonnie7 just switch the bullet and guy coordinates in the AngleBetweenPositions.

It worked, there’s now only 1 bullet!
However, now the bullets are spiraling WAAAY too fast. And if I lower the angle, the bullet just flies off screen. Is it possible to control the speed of the bullet?

Also, the bullets are no longer centered on the guy

Could you please send me a GIF of your results to see how they compare?

Sorry, I have not really time at the moment. For the centering problem you could move the origin point of guy to the center, this seems to solve the problem. Just be aware that this could affect other events where the origin point is important.

For the speed issue the DistanceBetweenPositions plays a role. The bigger the distance the faster the bullet. There is probably a way to get better control of that but at the moment I have no particular idea.

Alright, I’ve made the changes. Here’s the code:

And here’s the result:

issue5

I moved the origin of guy to the center, but the bullets still refuse to stay centered. Also, altering the distance DOES speed up the bullet, but even at such a low distance, the bullets are still travelling too fast. How can I make it so that I can adjust the speed like in this older GIF?

issue4

This older GIF has the right speed I want, but with flickering double bullets. What I have now has no flickering, but the movement isn’t right. There must be some sort of way to get the best of both worlds, right?

Nevermind on finding a solution for this, I looked up a Construct 3 tutorial on how to do this and applied it to GDevelop instead

issue6

Basically, I’m spawning a bulletspinner object which rotates. The bullets stick to the end of the spinner as it scales up, giving a perfect rotation I want.

However, now there’s another problem: The timer is spawning multiple spinners, but all the bullets are just sticking to the first spinner. How can I make each individual bullet stick to the end of it’s corresponding spinner? For each didn’t help at all for this, so I’m not sure what to do.

And yes, other guys stealing the bullets are still a problem too

Hi, great to hear that you found a solution.

Using the ‘For each’-event is definitely the right thing to do but first you have to link the bulletspinner and the bullet. In the ‘For each’- event you have to take the two linked objects into account.
I just posted an example on how that works for another post yesterday, but the actual method is the same.

1 Like

I can’t believe it worked, you’re a miracle worker!

The bullets are now spiraling appropriately! I even went ahead and used this philosophy to make the other guys play nicer with each other, and now nobody is stealing anybody else’s bullets anymore!

I decided to make this more customizable, by adding the ability to shoot different amounts of bullets and adjust their rotation speeds too with instance variables.

Although, that’s where I’ve encountered a problem…

When I set the rotation speeds and distance speeds of each guy, all guys with the same state instead just share whichever one has the biggest instance variable. For example:

issue7
(The GIF is crap, I know, but trust me, they're spinning)

The instance variables are bulRotSpd (Rotation speed), and bulRotDist(Speed of the outwards spiral).
Guy on the left: bulRotSpd = 200 / bulRotDist = 0.090
Guy in the middle bulRotSpd = -50 / bulRotDist = 1
Guy on the right: bulRotSpd = 10 / bulRotDist = 0.001

However, all guys are rotating at 200 speed, and 0.090 distance. How can I prevent them for sharing their instance values?

I also have a question after this, but I’ll ask one thing at a time here to avoid swamping anyone this time

Use a repeat for each guy as a subevent of the first event from your screen snip. As it stands you could have mulitple guys that meet the conditions, and it’s anyone’s guess which guy’s values gets used.

Also, in this event :

you are not using a condition to specify which guy object to use.

I tried this, but it didn’t work. Did I do something incorrectly?

Nvm, I’ve once again found out a solution. I just needed to link the guy and bulletspinners too.

Now they’re rotating perfectly, and it’s very customizable as well.

Sorry to be a bother, but there’s one last issue…

For this, I’m going to unhide the bulletspinners to demonstrate:

issue8

The bullets have the Destroy Outside of Screen behavior, and when the bullet is deleted, you can see that some of the spinners are stopping in place if you look closely.

What I want is for the spinner to be deleted with the bullet to prevent a data overflow, but my code doesn’t delete them:

How can I check when the bullet is destroyed outside of the layout to destroy the spinner?

There is a “Destroy when outside of the screen”-behavior which you can attach to your bullets and the spinner.

I know. Plus, putting the behavior on the spinner does nothing because it never goes offscreen

Ah, okay I missed that point. I am just guessing but I would try another ‘For each’-event when you check for the bullet position and destroy the spinner.

Alright, I just tried it out.

Unfortunately, it didn’t work

Could you post the event that did not work?

Sorry, here it is

Using for each bullet didn’t work either btw

All the changes were the exact same outcome

Okay, try “take into account all bulletspinner linked to bullet” instead. The order here is also important.

Sadly, it didn’t work. Same outcome as before.

Also, I’m adding a lifespan system to the bullets too, so is there a condition to check if the bullet is deleted or no longer exists?

The general problem here is that the bullet is deleted and then the bulletspinner which is linked to the bullet should be deleted as well. But if the bullet is deleted first there is no link anymore. I would suggest to delete both at the same time.

This is how it works for the example (I changed the names, the screenwidth and height / 1.5 is just for me to see that both objects are deleted).

I had to modify the code a little bit, switching the bulletspinner in position to bullets, and I changed the values of offscreen to my liking, but I can confirm that it’s definitely working now! Thank you for your help!

1 Like