Help with nearest obj

Discussion and feedback on Construct 2

Post » Wed Aug 16, 2017 10:33 pm

Ok so I have a combat system set up so that when I shoot an enemy 10 times, it dies. But if I make many of that enemy, they all die when one gets shot 10 times, I've tried using nearest condition, but this error still occurs. I've even mixed and matched with the condition (switching player and enemy, etc.) but it keeps happening. :x :(
B
6
S
2
Posts: 11
Reputation: 472

Post » Thu Aug 17, 2017 1:13 am

@dwtiger

Have you tried

Enemy >> Health Bar >> is Less Or Equal to >>0
Sub Event>>For Each>> Enemy >>>Destroy

That it should apply only to the Enemies that have health = 0 or less

You will find the " For Each" in the System >> For each>> Then choose your enemy

Note: you do not need the Nearest condition
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Thu Aug 17, 2017 1:20 am

In the for each section, do i put the enemy as the object for the loop? (And thanks for the help.)
B
6
S
2
Posts: 11
Reputation: 472

Post » Thu Aug 17, 2017 1:21 am

dwtiger wrote:In the for each section, do i put the enemy as the object for the loop? (And thanks for the help.)


yes the ones you want to destroy
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Thu Aug 17, 2017 1:24 am

@dwtiger

I had a capx with a pretty basic set up of health bar if wanna have a look

https://www.dropbox.com/s/otw0zo9wcxh1xax/Create%20Healh%20bars%20to%20multyple%20instances3.capx?dl=0
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Thu Aug 17, 2017 1:51 am

Not letting me run it. Currently running most recent version of construct 2.
B
6
S
2
Posts: 11
Reputation: 472

Post » Thu Aug 17, 2017 1:58 am

I have the screenshots here (also i have the variable for enemy damage taken as health, planning on changing it soon.)
http://i.imgur.com/Jln4vhI.png
B
6
S
2
Posts: 11
Reputation: 472

Post » Thu Aug 17, 2017 2:01 am

B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Thu Aug 17, 2017 2:12 am

dwtiger wrote:I have the screenshots here (also i have the variable for enemy damage taken as health, planning on changing it soon.)
http://i.imgur.com/Jln4vhI.png


you can install the beta or you can

right click on my capx extract it with winzip

it will give you 4 normal folthers and one extra black that it looks like the capx with diferent name
then you right click in that new black capx and open it with notepad

then look for this <saved-with-version>24500</saved-with-version>

then just change it to your version and then save it, after that you will be able to opn it

example if you have the r244 version then change the <saved-with-version>24500</saved-with-version>

to the version <saved-with-version>24400</saved-with-version>
Last edited by tarek2 on Thu Aug 17, 2017 2:26 am, edited 1 time in total.
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Thu Aug 17, 2017 2:15 am

can you share your capx I will quick have a look

ok I can see your picture now , use families will easier and better performance if you have many enemies

it looks like you adding to the health instead of subtracting

Try this then

health >>is equal = or more than 10
subevent >> for each enemy >> Action Destroy


here is the pictures from my events
https://www.dropbox.com/s/hemg3o2wapsloau/Health%20bar%20pic.png?dl=0
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Google [Bot] and 2 guests