Destroying only one instance of an object

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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 <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

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

    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)

    dropbox.com/s/xt8f70kz652stkl/screenshot3.JPG

    Thanks again!! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Put enemy in 'pick nearest' event instead of player. :)

  • Hello vee41,

    Thanks for the reply. Hah i feel ashamed <img src="smileys/smiley9.gif" border="0" align="middle" /> that i didnt think of that.Anyways thanks for quick replies and hope to finish the game soon and release my first game... <img src="smileys/smiley2.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)