3
votes

I have a world in box2D where I use a 2 edge body to represent a wall (I have 2 because there can be a different angle between the 2 objects).

My problem is that every time a circle object is traveling along the first edge, when it reaches the second edge it detects a collision and bounces off the wall. Even if there is no angle between the 2 edges.

Also if my circle object hit the junction between the 2 edges (with or without angle) it bounces to a undetermined direction.

How can I fix or prevent that behavior?

Collision detected

enter image description here

Angles are approximated

1

1 Answers

2
votes

For colinear edges I would add some preprocessing that will combine two colinear edges into one to get rid of such problems.

For the second case. The only that comes to my mind is to detect collision with multiple edges (with some tolerance, for sure not exact value) and then calculate bisector of the edges of interest - based on that, and the angle that circle object hits the edges calculate new angle.