How to create a sided hitbox.

0 favourites
  • 5 posts
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • Let's just say I have a enemy. This enemy can be killed but jumping on top of it. But it hurts you from the sides or the bottom. How do I make hitboxes like this that only apply to one side?

  • I think it's easier to determine if the player's position when they collide with the hitbox.

    For example, if their Y coordinate is less than the enemy's top edge, that means they're beside our below it, and should get hit.

    Otherwise, the player is above the enemy, and can stomp on them.

  • Mario games handled it by checking the vertical velocity of Mario when hitting the enemy.

    Mario collides with enemy

    Mario y velocity >0

    — kill enemy

    Mario collides with enemy

    Mario y velocity <=0

    — kill Mario

  • Mario games handled it by checking the vertical velocity of Mario when hitting the enemy.

    Mario collides with enemy

    Mario y velocity >0

    — kill enemy

    Mario collides with enemy

    Mario y velocity <=0

    — kill Mario

    That's a much better solution! Thanks for sharing that!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Mario games handled it by checking the vertical velocity of Mario when hitting the enemy.

    Mario collides with enemy

    Mario y velocity >0

    — kill enemy

    Mario collides with enemy

    Mario y velocity <=0

    — kill Mario

    Thanks! This makes sense. And I guess it could work with any direction, as well!

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