Player only shoots at original enemy

My player only shoots at the original enemy. once they die it only then shoots at another. i figure it is very simple but don’t know what to add.

There’s not enough information for how do you want to choose which enemy should be targeted.

You want it to shot random enemies? Enemies with cursor on? The closest enemy?

When you fire the bullet at enemy, you never specify which enemy. GDevelop filters the list of object when you specify a condition, and then tries to apply the action to all the objects in that filtered list. You don’t have a condition that filters the list of enemies. And because you only fire one bullet, GDevelop has chosen the first object on the unfiltered list to aim at.

As @gigakoks wrote, you need to specify which enemy to shoot at, and you do that by adding a condition to the event that narrows down the list of candidates. You can select the closest, the healthiest (if you keep tabs on enemy health), the unhealthiest or whatever other conditions you want to set.

I’m sorry I guess the first enemy hit box it runs into but also the nearest would work if that is easier.

how would i do the nearest? also that is another issue even though it is an object event all of my enemies health is tracked together. when one gets hit they all go down.
p.s. Are you always on the forums you always are like the first person to help me lol.

Like this :

Again, it’ll be the conditions you use to filter the enemies.

Not much else to do when you’re stuck in a cupboard under the stairs for 23 hours a day…

1 Like

Darn, that should’ve been obvious. Thank you! You deserve a raise!

ok so I’ve been trying to figure it out but cant it does not change the value of the object variable but it changes the Heart animation for every enemy. i though it would know which to change because they are linked

Also all the enemies shoot at the player when they are touching the original ring. i cant do only the closest because sometimes multiple enemies need to be shooting

p.s. I’m sorry I’m difficult, and really appreciate your help.

You should look at changing the health animation as a subevent of the event where you change Enemy.BlackHealth.

I would make those events into 2 nested subevents, and attach this as a subevent of the event that changes Enemy.BlackHealth (hope that makes some sense), which I think will make a difference (the first event is one I made up, it’s an example, but the two sub events are the real deal) :

Also, make those first events as one subevent of an “at beginning of scene” event :

BTW, you’re not difficult. Not in the slightest. Keep those questions rolling :smiley:

Aight, so everything you said made it work the only missing thing is that only the original shoots at the player. I would need it so multiple can shoot at the player at once but right now only one shoots at him even though it is an object variable.

in the past I used “for each instance” but that seems to negatively effect object variables.
(I’ve never really used object variables prior to this)

See what the following does for you. I’m haven’t tried it, but I think it’ll work, and do what you’re after. I replaced the 2 repeats over all the EnemyRing objects with one repeat over a subset of them. It’s a bit more efficient.

I believe I got it working. it needed a few more “trigger once” prompts but thank you! ill ask if i need more help!