Creating a chain effect for a bullet

I’m working on a tower defense game and I’d like to add in an upgrade that will allow bullets to chain between a certain amount of enemies. I want the bullet to select the closest enemy that is not the one it is currently damaging or one it has previously damaged and go towards it. I’m still very new to GDevelop so I don’t know if this is really simple and I’m just unaware, but I tried doing it a way I thought could maybe work.

I tried this the first time, with “enemies” being an object group I had hoped I could use in order for the bullet to seek any enemy. I have no idea if that is how object groups work or if I can use a group like this at all, so I then tried it with just a single enemy type, also to no luck.

What would be the best way to go about this?

IDK what you’re doing, I’ve never really messed with some of the events you’re using, especially the “link” one.
Instead of the whole link thing, which is what I assume is wrong, just go to the nearest enemy that isn’t in collision with the bullet.
Easy.
If you don’t know what that means…
Just reply to this comment.
I don’t feel like doing a bunch of screenshots for this, because I have my own game to make.

I fear the whole reason I made the post is because I don’t know what most of this means, so I would greatly appreciate the assistance

This.

  1. Don’t use subevents like that, if they don’t have actions and you don’t actually need the sub event, just put all the conditions together in one action.
  2. Try replacing the “Take into account all “NormalEnemy” linked to Bullet” with “Bullet is in collision with “NormalEnemy””, and invert it.
    I hope this works.

If I may… I did this with a chain lightning attack in a project and I use a variable to switch if the target is being hit. So like all possible targets would initially have a “zapped” variable set to false.
If a target is struck by a lightning attack, it’s object variable “zapped” would be switched to true.
When picking the second target, set a condition to check that “zapped” is false. Same goes for any succeeding target.
Targets with the “zapped” condition set to true will only get it switched back to false when the lightning attack is completed.
Hope this helps.

1 Like

Why is it “BallEnemies” instead of “Enemy”?

1 Like

i have project (well that very project which is linked in my message) called test project
Its sole purpose is for me to set up something and show events how they look and provide link to preview so any1 can test it so i can prove it is working with these exact events

I made multiple ball objects each with different color
But then i realize it was stupid and i added each color as separate animation to one single Ballz object and removed other copies for object list

Meanwhile to be able to address all ballz before i changed them to single object
I had them in BallEnemies object group
That is why you see group in condition and object in action
Where right now BallEnemies group contain only one object

However it is confusing to someone who do not know that
So THX for pointing that out i gonna fix it in a moment

1 Like

and btw, while you are doing that, i will try to experiment on another methods i found online… and still, thanks for trying :smiley:

1 Like