0 Favourites

How do I destroy an object when another is placed on it?

  • Hi guys, hoping there's someone who has some ideas on how to help me with this.

    I'm building a game where the player can drag and drop ship components onto a grid to design their own ship, however I'm having trouble making progress with 2 aspects.

    When the player drops a component on a cell of the grid where a component is already placed, how can I make it so that the original component is destroyed?

    I've tried this via:

    [Ship Family] "is object over lapping" [Ship Family] --> Destroy [Ship Family]

    on the release of the drag and drop, however this doesn't seem to do anything.

    I've also tried:

    If [Ship Family].X = [Ship Family].X

    and [Ship Family].Y = [Ship Family].Y

    then destroy [Ship Family]

    However of course, this just destroys all objects in the family.

    Would I be able to achieve this through the "Pick nearest" event, and say if nearest is <X then destroy? I've no experience using this event so i'm not sure how to go about this.

  • You can make a second family with the same objects in it. Then you have a unique name to compare to.

    [Ship Family] "is object over lapping" [Ship Family Tester] --> Destroy [Ship Family Tester]

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Ah fantastic, works a charm. Thank you!

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