Destroying only one instance of an object

Get help using Construct 2

Post » Mon Jun 10, 2013 2:54 pm

Hi everyone,

I am new to construct 2. I am trying to make a game in which if you are near your enemy and press a button, timing bar appears.if u press another button in the correct timing, then the object which is near you should destroy(more like prince of persia style....when u click the button when the knife flashes u get a clean kill). But the problem is all the other instances of the object which are far away also gets destroyed.

i tried instancing a variable called death and setting its value and then destroying the object if it is true...but i still have the same problem.

is there a way to pick a object which is 10 pixels near my character and delete only that instance of the object.

I think it has something to do with iid and uid but i cant figure out how to do it.

Please help me...thanks in advance
B
2
Posts: 3
Reputation: 181

Post » Mon Jun 10, 2013 3:20 pm

Easiest way would be with the Pick nearest condition. Pick the enemy nearest to Player.X, Player.Y.

That will choose the actual instance of the enemy to destroy. If you want to additionally only choose enemies within x pixels, create another condition in the same event to Compare two values, first value being Distance(Player.X,Player.Y,Enemy.X,Enemy.Y) and the second being your desired distance, e.g.: 10.
B
57
S
15
G
11
Posts: 912
Reputation: 12,581

Post » Mon Jun 10, 2013 6:14 pm

Hi GeometriX

Thanks for the quick reply.I have tried the thing u have said but i am not able to get the result i want.the same thing happens again.i have two instances of the object and when i try to destroy one both gets destroyed.

I think i am not getting the condition in correct order or something.Anyways i have here the screenshot of my event sheet.Can u please go through it and point out the mistake.

in this shot i have trying to use the distance method u said....
https://www.dropbox.com/s/hmzolgn021iqhz7/screenshot1.JPG

In the next screenshot i am trying the find pick near method(I am not sure if this is what you meant.if not please elaborate)

https://www.dropbox.com/s/xt8f70kz652stkl/screenshot3.JPG

Thanks again!!
B
2
Posts: 3
Reputation: 181

Post » Mon Jun 10, 2013 6:23 pm

Put enemy in 'pick nearest' event instead of player. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,242

Post » Mon Jun 10, 2013 6:43 pm

Hello vee41,

Thanks for the reply. Hah i feel ashamed that i didnt think of that.Anyways thanks for quick replies and hope to finish the game soon and release my first game...    
B
2
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: fisholith, RetroSpock and 13 guests