Destroying Enemies Only When Landing Directly On Top Of Them

0 favourites
  • 3 posts
From the Asset Store
John is a fearless pirate and has ventured to seek treasure in uncharted lands
  • Hi everyone,

    I'm working on player and enemy collision similar to something like Super Mario Bros; I want to ensure that the only way that the player can destroy an enemy is if they jump and land directly on top of them.

    Right now, I'm spawning enemies and then having them spawn a 1px high sprite which matches their width to act as hit detection from above. This is then pinned to the top of the enemy sprite. If the player touches this line whilst falling, the intention is that it will destroy the associated enemy that it's pinned to. The problem I have is that it currently destroys all instances of enemies that are on the screen. Is there a way to only destroy the enemy attached to the line sprite that the player hits or a more elegant solution to this problem?

    Thanks for your help!

  • Player > On collision with (Detector)

    System > Pick by comparison ... Enemy .. Enemy.UID .. is equal to .. Detector.PinnedUID

    ______________ destroy Enemy

    ______________ destroy Detector

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Worked perfectly, thank you! I love UIDs!

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