3
\$\begingroup\$

I'm planning to develop a top-down oblique mobile game (like the one in the screenshot below), but I'd like to understand something before I start:

When I'm working on collisions, where should the fixture for collision be? Should it be at the character's feet, or elsewhere?

enter image description here

\$\endgroup\$
1
\$\begingroup\$

When you have a 2d game with an oblique perspective, then a collider should represent the floor space which is occupied by an object. The collider size should be independent from how tall the object is. If you use the pixel height and width of the sprite to generate a collision rectangle (as you would do in a straight top-down or side-view perspective), then you will get the weird result that tall objects occupy more vertical space than short objects but not more horizontal space. You should instead choose a radius for a collision shape which represents the thickness of the object at the thickest height.

Imagining all collider primitives on the floor level is usually a good mental model. You could of course also imagine the colliders on chest level or head level. But in the end the collider height really just exists in your imagination. When you have pure 2d game mechanics, then all colliders (moving objects and environment) need to be on the same height anyway. So using a different height than zero just means you add a constant value to all y-values in your collision detection code. This won't have any game-mechanical consequences. So there is no value in doing that.

The green ellipse around the feet of the one character on the screenshot could be a visualization of its collision circle.

Another mental model you can use is to imagine your collision shapes as infinitely high vertical columns in 3d space.

I am looking forward to playing your game.

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

This entirely depends how you would like your game to behave.

Can other humans/creatures walk behind your hero in such a way that your hero's head hide their fit? Then the collision should be focused on the legs. There is not "should be" or anything like that. When you are making the game, you are in control of what is happening. It only changes how the game behaves, which in this case, there is no wrong/correct choice, only which one you like most.

|improve this answer|||||
\$\endgroup\$

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.