I'm building a 3D platformer, and I'm having issues figuring out how I should determine whether the player has effectively jumped on an enemy to kill them.

My current approach uses "hurtboxes" above the enemies like so:

hitbox picture

And if the player has a negative velocity and isn't grounded while they collide with that hurtbox, it will kill the enemy. This works pretty well, but isn't ideal because the hurtbox being too big makes killing them easy, but making it too small results in unexpected failure to kill the enemy, which would be frustrating to a player.

Is this typically how 3D platformers deal with this issue, or are there better ways?

Thank you!

  • 1
    \$\begingroup\$ This screenshot appears to be from the Unity engine, but you did not tag this question as Unity. Does that mean that you want a general answer which can be applied with any technology stack, or would a Unity-specific answer suffice? \$\endgroup\$
    – Philipp
    Oct 6 at 8:00
  • \$\begingroup\$ What is it about using a large hurtbox that makes it too easy? Maybe there's an important game design decision that needs to be made that can keep the larger (more reliable) hitboxes. \$\endgroup\$
    – Romen
    Oct 6 at 20:48

If you have a ground detection empty object parented to the player, you can use this,

Do A box cast from ground detection like this,

Collider enymyHitInfo  = Physics.BoxCast(origin , size , angle , direction); 

and if the collider is true and the colliding object has "Enemy" tag then you can Destroy gameobject, like this ,

if(enymyHitInfo.collider != null)

This is all assuming this is C# and unity the same would apply to any other language but the syntax changes. That's all.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.