V
V
Vitaly2014-10-08 11:32:16
Box2D
Vitaly, 2014-10-08 11:32:16

C++, Box2d: How to fix tripping over box corners?

There is a rectangle character that can walk, run and jump.
3050a830ae8b49899220ca214f05c10b.PNG
The entire game world consists mostly of blocks of the same size (some of them can be triangular (slopes) or in rare cases repeat the texture in shape)
The first problem is that when running or sliding the character stumbles over the corner of the block and stops, as if he had crashed into wall (if you step back and try to walk again, you no longer stumble)
c8a41869bcee405f8a7a62ff0412bc74.png
The same problem occurs if the character falls against the wall, and with some probability also stumbles over the corner and stands on the corner until he jumps or does a micro- step in a groan.
At the same time, I want to teach the character to move from block to block if he moves with enough speed:
0c570364667844e49a08771e46640a47.PNG
But this is not possible even at over speed, the character still stumbles and falls between the blocks
0fcfbd459e8c4b0cb0e0ca6572e98fa8.PNG
. I assume that I need to add a modification to the collision check and raise the character to the level of the block if he hits the block at a depth of, for example, 3-5 pixels ( 0.3-0.5 meters) at a speed of at least one meter per second (in any direction).
Making rounded corners of the shape helped the character, but I don't want to resort to this option, because the character needs to cling to the corner of the block without sliding off the cliff.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mamkaololosha, 2014-10-08
@mamkaololosha

Box2D can only push 2 pieces and that's it. Then turn on your brains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question