How do I Destroy Object on Return Pressed

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello. In my game that I am making, I was trying to make an object that is destroyed by the sprite colliding with it and then destroying it when Enter (return) is pressed. I have tried to attempt it but it doesn't get the job done smoothly and you have to jump on top of the object in a certain spot in order for it to work. Any advice on how to fix this?

    Thanks

  • Sorry, but what are you trying to achieve?

    When is the object supposed to be destroyed? When you press Enter after it has collided?

    If that is the case, you can simply store the collided object's UID in a variable (global or instance doesn't matter).

    You do so by adding an event "Player: On collision with [object]".

    Underneath that, add an action "Set value "collisionUID" (your variable) to [object].UID".

    (Since the colliding [object] gets picked by the event, the correct object's UID will be stored.

    Now, you add your keyboard event "On Return pressed".

    As a sub-event, add an expressional picking condition, picking [object] with the expression [object].UID = collisionUID.

    On that condition, add the action [object]: Destroy.

    Done.

    ____________________

    You can also add a condition to the keyboard pressing event: "If 'CollisionUID' is not 0" and an action after the destroying action: "Set 'CollidionUID' to 0".

    This prevents destroying an [object] that already has been destroyed.

    If you need further help or a .capx, give me a shout.

  • Sorry, but what are you trying to achieve?

    When is the object supposed to be destroyed? When you press Enter after it has collided?

    If that is the case, you can simply store the collided object's UID in a variable (global or instance doesn't matter).

    You do so by adding an event "Player: On collision with [object]".

    Underneath that, add an action "Set value "collisionUID" (your variable) to [object].UID".

    (Since the colliding [object] gets picked by the event, the correct object's UID will be stored.

    Now, you add your keyboard event "On Return pressed".

    As a sub-event, add an expressional picking condition, picking [object] with the expression [object].UID = collisionUID.

    On that condition, add the action [object]: Destroy.

    Done.

    ____________________

    You can also add a condition to the keyboard pressing event: "If 'CollisionUID' is not 0" and an action after the destroying action: "Set 'CollidionUID' to 0".

    This prevents destroying an [object] that already has been destroyed.

    If you need further help or a .capx, give me a shout.

    I would appreciate a .capx because I'm not exactly sure how you apply what you said

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here you go:

    Download

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