Sorry about the vague title, it's kind of hard to say what I want to do in a few words.

In my top-down game, I'm having a problem implementing proper collision for walls facing north (that is, you can actually see the surface of the wall, as opposed to the other directions, where you can see just the top).

I have a proper bounding box that detects the alpha values of the sprite, and generates a proper bounding box around only the visible pixels, like so:


However, when dealing with walls, I run into a problem. With my current implementation, there are two options I have:

  • Set the walls so that the player can pass through them. This leads to the player walking "on" the walls, like so:

enter image description here

  • Set the walls so that the player can not pass through them. This leads to the player's head colliding on the bottom of the wall, like so:

enter image description here

In the image, the player can not move forward any more.

My solution to this, would be to place the bounding box around the player's feet. However, this would interfere with my alpha-based system, and other collision systems (enemies hitting the player, etc.)

How should I approach this?

If my question is unclear, I can provide more images and descriptions of what I'm trying to achieve.

  • 1
    \$\begingroup\$ What about the obvious solution, use 2 hitboxes and only use one for collisions with the wall. Whats wrong with that ? \$\endgroup\$ – dimitris93 May 22 '15 at 23:29
  • \$\begingroup\$ Agreed with Shiro - you describe the problem as that you need 2 different behaviors for 2 different circumstances. In that case it's wise to use 2 different systems! \$\endgroup\$ – Raptormeat May 23 '15 at 0:32
  • \$\begingroup\$ That's it! Thank you! @Shiro And thank you @Raptormeat! (: \$\endgroup\$ – Tetramputechture May 23 '15 at 0:33

Your Answer

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

Browse other questions tagged or ask your own question.