2.5d - approching from top and bottom

So, I’m using box2d for my 2.5d game (think double dragon, tmnt arcade, castle crashers) where you can move around on the z-axis (faked as y-axis movement). Basically, I have box2d only doing collision if 2 entities have the same z coordinate or a z-coordinate within the depth. All is fine, except when I approach an entity from the top or bottom.

So yeah, approaching any box2d entity from the top or bottom within the correct x will make the player bounce back once the z becomes the same as the entity - which makes sense because then it starts detecting collision, and it detects a box inside a box. How could I circumvent this? Thanks.

maybe you should do some sort of grid or something like that,
look to this picture :

http://s20.postimg.org/ry1qddyv1/Sans_titre_2_copie.jpg

the player is in the “yellow-part” and the entity box is in the “blue-part” which mean they can never collide even if they truly do, i believe the best way to this is to check where is the bottom of your boxes (player and enemies feet) if the bottoms are in the same level, then you could do the rest of the collision detection.
PS :
i never tried to do something similar, i hope i helped
good luck

You could also internally handle object movement as a 2d top-down game, and then hack-in vertical movement (jumps, etc).

I’m already doing this, however eventually the player z will match the entity z and then 2d physics will be applied and the player bounding box will be inside the entity bounding box, which doesn’t work. Someone else on gamedev.stackexchange already suggested only making collision boxes on the feet, which I wanted to try avoiding, but now is probably the only option.

Ah, I don’t know enough about box2D to know if this suggestion would work, but why not just get the position/size data from the object and perform your own collision check? Like, get the bounds in 1D across X of the entity that wants to move between Z layers and check if it will collide with any other entity on that Z layer (Only need the 1D across X of each one). It’ll at least tell you if a collision will happen from moving between Zs.

Set the bounding box to the bottom part of the object.

To calculate the bounding box use


public void calculateBBox()
{
    bounds.x = object_x;
    bounds.y = object_y + (image_height - image_height/4);
    bounds.width = image_width;
    bounds.height = image_height/4;
}

am afraid that’s the only solution, when faking 3D in games you must do something like that, for example in a Top-Down rpg (pokémon) when your player hit the top of a Tree it will not stop moving, cause it’s not possible to hit the top of the tree in real life, so the only way for the player to stop is when he hit the bottom of the tree, and i think it’s the same for you, if you look in those two pictures, you’ll know that the only “simple” way to realize that is by checking the collision in the bottom 1st, then look for the other

http://s20.postimg.org/ajn2951h9/nobutto.jpg

http://s20.postimg.org/vukmdejlp/butto.jpg

another thing , i think you could (or must) check the level of your entities, and i think it’s better to do it on the bottom too,
suppose you want to shoot an enemy, you must be in the same level to be able to hit him (unless you can shoot in many direction)

http://s20.postimg.org/a9fjpsmv1/level.jpg

so IMHO, the best solution is to make a grid, if the 2 objects are in the same row then you can check for collision,
Question :
why you want to avoid making collision boxes on the feet ?

There are several problems I envisioned with making such a small box - mostly that I’d have to use another body for hit detection and other things.

Believe me, this is how you do it.
always