Destroying Enemies Only When Landing Directly On Top Of Them

Get help using Construct 2

Post » Mon Aug 14, 2017 5:06 pm

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!
Posts: 10
Reputation: 245

Post » Mon Aug 14, 2017 9:37 pm

Player > On collision with (Detector)
System > Pick by comparison ... Enemy .. Enemy.UID .. is equal to .. Detector.PinnedUID
______________ destroy Enemy
______________ destroy Detector
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 15, 2017 8:10 am

Worked perfectly, thank you! I love UIDs!
Posts: 10
Reputation: 245

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 47 guests