How to create spiraling bullets

Greetings,

I’m testing a POC to keep bullet patterns for reference, and I’m currently stuck on something.

See, when the bullet is fired from the “guy,” I want the bullet to sort of curve as it flies outward, basically spiraling around the origin of where it was shot from, just like this:

nightcrawler

Here’s my code:

Can somebody help me out with this please? Thanks in advance

Changing bullet angle just spins the bullet object.

You can try using “Put the object around another” action, increasing the distance and angle every frame. Something like :


(the AngleBetweenPositions() may need the bullet and Guy positions swapped in the parameter list. I haven’t tried it out)

Also, you won’t need to add a force to the bullet, and you’ll need to have that “Put bullet around guy…” as a separate event.

2 Likes

Okay, I did what you said, but I’ve encountered two new problems. Here’s the code:

And here’s the result:

issue1

The two issues are:

  1. The bullets are rapidly flickering, which is the result of the bullet travelling WAYYYY to fast. The “guy” is only supposed to be shooting a single stream of bullets, but this issue makes it look like he’s shooting two streams. Is there any way to slow down the bullets?

  2. Those other “guys” are in an inactive state, but when active, they shoot the same bullet object with different properties

(E.g. state 0 shoots normal bullets with different animation, state 1 shoots sine bullets, state 2 shoots two different speed bullets, state 3 shoots 4 bullets in a spread out fan, state 4 shoots a rotating stream, etc. The guy I’m working on now is state 5, the spiraling bullets)

To the point, whenever ANY of the other guys are active while state 5 is active, the spiraling bullets, as well as ALL bullets will attempt to spiral around the OTHER guy instead of the guy they’re supposed to. Do I have to link the spiraling bullets to each guy with a state of 5?

(Note: When the “put around” event is placed as a sub event, the bullets just spawn, but refuse to move. I even tried to use time scale to slow down the scene to see how fast the bullet is moving, but the bullet is apparently so ludicrously fast that it completely ignores slowed down time)


EDIT: I think I may be on to something here. I modified the code to look like this:

And now THIS is the result:

issue2

This DOES make the bullets move a lot nicer, and it sure is quite a spectacle, but it’s still not quite what I’m looking for. The bullet doesn’t flicker anymore, but that second bullet parallel to the other still implies that it’s spiraling too fast.

Also, I want each bullet to come out of the guy shooting them, not spawn in the expanding ring. I tried to use state variables and linking the guy and bullet, but this just breaks the code.

Additionally, these events are STILL applying this effect to EVERY bullet on screen, rather than the ones being shot from this one specific guy. Again, I tried state variables and linking, but they don’t work.

Is it possible to salvage this and get it working properly?

The missile extension might help you achieve this

1 Like

Missile extension? When I look through the behaviors, I can’t find any missile extension. Is it under a different name, or is it something I need to download from somewhere else?

Go to the project manager, under extensions/functions, click add extension. Search for missile extension. There is info about how to use it in its description

I already did look there, and none of them are called missile. If I check the checkbox that says missile, all that pops up is homing projectile

Is anyone still there?

Oh sorry :neutral_face:, the extension’s name is homing projectile. I got a bit confused with the names

1 Like

Ahh, okay. I tried using this, and I’m not sure how I can make it so bullets can spiral outwards? The bullets just home in, not spiral

I think there is something called turning radius you can change. I was able to make it so that the projectile will spiral and home towards the target. I am not sure if I used another properties to achieve it, I’ll check and let you know

Alrighty, I tried it and…

issue3

Now, I know, I pointed the missile the wrong way, but the movement of the missile object is not quite what I’m needing. I want it to spiral around AND outwards. Also, each missile created after the first one doesn’t even move, and if there are any other guys in the scene, the missile will orbit the wrong target.

I don’t think the missile extension is going to work out for me. MrMen has already provided me with this code:

With this as the result:

issue4

The bullets are definitely moving like I want them to, but I just need help ironing it out.

Despite only 1 bullet being spawned at a time, you can see that two bullets are spiraling around the guy, and that the bullets are rapidly flickering. Somehow, the bullet is reflecting itself to the other side of the guy, creating a sort of illusion.

Also, if any of the other guys are active, the bullets will all spiral around that one guy instead, as well as their own bullets. How can I make it so the bullets only orbit around their individual owner?

And sorry that the missile idea didn’t work out.

Is anybody still there? I’m starting to become discouraged that what I’m trying to do is impossible, and this is the best it can possibly get. Is that true?

Hi, unfortunately I have no solution for the problem. I just can confirm that the code works for the spiraling movement. The problem is indeed that it visually produces two bullets but according to the debugger only one is actually created.
That’s definitely not the best it can get and don’t get discouraged, there is a solution that does exactly what you want.

There is? Can you provide a link to the thread if there is one with the solution?

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