Destroy instance without picking it

0 favourites
  • 4 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hi there, i need a little help.

    Following Situation:

    1 Bullet

    20 Targets (Instances)

    Event: On Collision Bullet -> Target

    Action: Pick Target beside the one which was collided (neighbor)and destroy this one.

    I think it is not possible to pick another Instance during this collisions event.

    Is it possible to destroy a instance without picking it ?

    What is wrong in my way of thinking ?

    Thank's

  • Yeah, I once did something similar. It went something like this.

    I had an instance variable on the "target" called objectID that was an internal ID I was keeping, so there would be no two targets with the same ID (probably I could have used the UID but anyway).

    Event: Bullet on collision with Target, Actions save Target.objectID to a local variable auxID, Target.X to auxX, Target.Y to auxY

    SubEvent

    - system pick all Targets

    - Target.objectID <> aux

    - Target.X > auxX - 100

    - Target.X < auxX + 100

    - Target.Y > auxY - 100

    - Target.Y < auxY + 100

          Action for subevent            -> Target.destroy

    This should destroy all targets within 100 "radius" (rather a rectangle but too lazy to do sin, cos etc) of the hit, except the one which got hit.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, OK

    I've learned:

    Pick All of a object which is involved in the collision, then reduce the picked ones with the help of local variables (NOR).

    Instead of adressing the uid directly.

    (The "Destroy-Range" effect is a cool and easy idea !)

    I keep on testing a little bit with this solution, thank you

    But anyway, i need first a pick and then destroy.

    Picking a third object under an collision event i.e. in a subevent isn't possible (?)

  • Yes you need to pick what you want to destroy, if you don't pick, it will destroy that which is already picked, i.e. the target that was involved in the collision. You got this right now.

    Not sure what you mean by picking a third object under a collision event, in a subevent. If you mean an object of a type that wasn't involved in a collision (e.g. "bullet" and "target" collided, and you want to pick "flower"), that IS possible, just tell the System->Pick all what to pick, or filter by that directly, i.e.

    event: bullet on collision with target

    event action: save coordinates to some local variables like in my post above

    subevent: flower->[...compare X and Y like in my post above...]

         subevent action->flower.destroy

    This should destroy all flowers around the collision, and not destroy the target or the bullet.

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