Destroy only a specific instance of an object

0 favourites
  • 8 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, I wanna have only a specific instance of an enemy object destroyed when the player attacks it (obviously, only the instance that was attacked). When I attack, every instance of my enemy is destroyed. The same applies when I have the enemy touch an object that makes it jump (all instances of the enemy jump, even the ones that didn't touch the object). Thanks in advance for any help

  • you are not picking (referencing) the object in your event.

    When Construct doesn't know which object is meant all objects are affected.

  • How do I go about picking just the instance that I attacked?

  • For that we'd have to see how you have your events set up.

    could be adding a check as subevent of the attack would work,

    could be using syatem for each,

    could be pichk by comparison,

    etcetera.

  • The short of it is, the player has an attack box sprite that's called when they hit a button. The event is set so that if the attack box collides with the enemy, the enemy loses a point from its health variable. Then I have a separate event where, if the health variable is less than or equal to 0, the enemy is knocked back, spawns some explosion sprites and then is destroyed.

  • You should post a capx using dropbox maybe, it can help when you need assistance.

    In your case, you select all the enemies and make the die. It could come from numerous cases... and a simple instruction could correct it. Without the code though, the only general solution I see is, in the event where you remove 1 from health, add a sub event where the trigger is "enemy.health<= 0" and the action is the animation you put later.

    Or if you want to keep the animation somewhere else (because multiple ways to die), you change the trigger with a Function call, and call that same function on the sub event I described before.

    As you are starting with C2, all this may make no sense, so I strongly suggest, as did LittleStain, that you post a .capx showing the problem the simplest way possible...

  • Adding the condition

    system for each enemy

    to the enemy health check event would probably solve it, but I would recommend reading the manual on how events work, it will make it more clear why this is happening.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)