How do I destroy objects by hitting them?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi everyone, me again. I watched some tutorials on how to destroy boxes like with SuperMario. However, I don't want to jump and simply collide with them, but I want to hit them while standing on them. My player is animated, so it looks as if he hits something below when you press arrow down.

    I already created one of these dummys. The box serves as container for the invisible Hitbox (same size as normal box). My idea was the following:

    System on start of layout: Hitbox set position to Box

    Conditions: Player on collision with Hitbox AND another condition: Keyboard: Down arrow is down. Action: Box destroy

    capx:

    https://www.dropbox.com/s/z12e57mprk7k0hu/2..capx?dl=0

    It is just not working...

    Thank you so much for answers!

  • It's because your player dummy box isn't actually colliding with the box. It's sitting on top of it. If you swap out player dummy box for player (the animation), it will work the way you have it set up.

    You could also set it up a couple different ways. One way is that you could probably play around with the collision polygons on your sprites to make it work. Another way, and what I would probably do, is to make an invisible detector sprite that follows the player box just under it and destroy the box if that detector sprite is overlapping the box and the down arrow is pressed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Jipii! To be honest, I don't really understand the difference between sitting on top and colliding with, but it works! No I try to add some animation to the box before it disappears.

    Vielen Dank also for the other options, which I'll keep in mind!

  • ok, update: The advice with the detector was the best solution. It's more precise now!

  • I'm glad to hear it's working for you. And I like your animation, by the way.

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