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.
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.
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.
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.