Making the enemy destroy when the Player is on top

0 favourites
  • 15 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I looked on the FAQ "Mario style: jump on top of enemy to kill it" which is exactly what I am trying to do. When I try to do it if they collide the enemy destroys, no matter if its on top or side to side. I want to keep the side to side where if it hits the player he will take damage. But if he jumps on him it will destroy the enemy. Please help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make another object the same size as your character. Match up the new object and your character in the editor. Pin that object to your character. Make the object invisible. Change the objects collision polygons so that it matches up with your characters feet. Make sure that you leave a pixel or two on each side, you might need to play around a little to get it exactly how you want it. Set up that object in your events so it does damage to enemies, rather then your character. Also, you may need to update the collision polygons on your character so you aren't also taking damage when you jump on the enemy.

    There are probably better ways to do it but that will work and get you started in the right direction.

  • Ok I am trying to do that but I am having trouble keeping the collision detection box pinned. I have't even tried to set it up where it is at his feet. It stays there for a little while and then starts to move as I keep going right. I am so confused and frustrated.

    Update: I tried On Collision Pin and Every Tick Pin oh also on created

    Every Tick doesnt even work it wont pin a tall. On Collison is the way I was doing it where it would stay there then start moving after you move so far its so weird.

  • Use at start of layout to pin it. If it's lined up in the editor you should be good.

  • That works thank you. I figured out why it was moving had it on the wrong layer had it on my HUD layer which has 0 paralax haha.

  • Ah, yes, that will do it. :)

  • Assuming you're using the platform behaviour just create a normal destroy on collision event and add the conditional "isFalling".

  • Akoji, were you able to get so that the enemy dies only when you land on top and not land on the side? I'm having difficulty making it so that only when you land ON TOP of the enemy does the enemy die. If you fall on the side of the enemy it should hurt you, at least when trying to replicate a Mario game. I don't follow how the invisible object for damage resolved the issue when landing on the side of an enemy..

    Assuming you're using the platform behaviour just create a normal destroy on collision event and add the conditional "isFalling".

    That allows you to fall on the side of the enemy to kill it (in other words, this method will not require you to hit the TOP of the enemy), which does not match with Mario games since in those games you die if you hit the side of Goomba instead of the top.

  • Mmm, what about making an invisible collider pinned on top of each enemy? Just a small sprite about half as wide as enemy. That should fix the "falling on side" issue.

    Actually, here's a capx

  • I did it by pinning a collision box on start of layout to the feet of the player. Then have that set where if it collides with the enemy it will destroy it. Once I am done with what I am doing I will post the capx for everyone would love some feedback on my first game.

  • Mmm, what about making an invisible collider pinned on top of each enemy? Just a small sprite about half as wide as enemy. That should fix the "falling on side" issue.

    Actually, here's a capx

    Ah of course, why didn't I think of that. Thank you for the advice and also thank you for including an example capx.

    I did it by pinning a collision box on start of layout to the feet of the player. Then have that set where if it collides with the enemy it will destroy it. Once I am done with what I am doing I will post the capx for everyone would love some feedback on my first game.

    I'm curious if that method will still allow you to kill the enemy if you fall on the side of the enemy because the feet of the player can still touch the side of the enemy as you are falling if the enemy is big enough.

  • Ah of course, why didn't I think of that. Thank you for the advice and also thank you for including an example capx.

    Anytime, mate :)

    > I did it by pinning a collision box on start of layout to the feet of the player. Then have that set where if it collides with the enemy it will destroy it. Once I am done with what I am doing I will post the capx for everyone would love some feedback on my first game.

    I'm curious if that method will still allow you to kill the enemy if you fall on the side of the enemy because the feet of the player can still touch the side of the enemy as you are falling if the enemy is big enough.

    I guess it will ;(

    Well, depends on how collider sprite is set up, but still might be buggy. Either way that works is fine, i think :P

  • > Ah of course, why didn't I think of that. Thank you for the advice and also thank you for including an example capx.

    >

    Anytime, mate :)

    I was trying to apply your example to this demo and I am getting some weird bugs.. I'm probably not doing it right <img src="smileys/smiley5.gif" border="0" align="middle">.. I'm also trying to put the bad guys into a Family (will create more characters later) and I think that is what is causing the issues.

    Issues:

    1. When an enemy is created, the collider does not follow the enemy properly

    2. Sometimes you can land on the head of the enemy and no damage is done... you just ride the enemy

    3. All enemies die when an enemy is killed (not sure how to specify only to kill the enemy that was stomped on)

    Here is the capx I am working on:

    https://www.dropbox.com/s/f38avjx9f0nbuuf/A2.capx

    Any suggestions or advice is appreciated.

    Meanwhile I will read up more on Families and such. I still have a lot to learn.

  • Oh, I see. Well, I didn't manage to make Containers work with families properly :(

    So here is an other way.

    No containers involved, but you need to add a variable to Collider object.

    looks like it's working fine, hope that helps:)

    P.S:

    2. Sometimes you can land on the head of the enemy and no damage is done... you just ride the enemy

    Hmm, try to play around with Collider width and position, might fix the issue.

  • Thanks for the help JJList. The way you handled pinning the collider works great.

    Sadly I have not been able to get the second issue resolved (sometimes being able to land on the head of the enemy). I have tried even making the collider ridiculously large and sometimes the Player still falls through the collider and lands on the head of the enemy. You can re-create this issue on the previous capx by going to the top platform and falling onto the enemies head (don't jump).

    I'll keep trying to figure it out but so far it has got me very stumped.

    edit: I'm thinking of just going off of your capx and building from there.. this issue has got me beat and I don't understand how it is an issue on my capx but not on yours <img src="smileys/smiley18.gif" border="0" align="middle" /> . I'm mostly just trying to learn right now so this really bugs me.

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