문제

I have a problem with collision between 2 bodies(one dynamic and one static). Lets say that I have wall and ball, I set filter which allows the ball to pass through the wall. It works good as long as I create sprite with body outside the wall body. The problem appears when I create ball at the same position as wall then the ball gets stuck or bounce or does weird things. I believe that it shouldn't has matter where I create the body if there is collision filter. Had anyone similar problem ?

도움이 되었습니까?

해결책 2

I still don't know why the problem appears but I know that it happens if I create boxBody and circleBody. I solved this problem using polygonBody instead of boxBody. Here is my code which create box from polygon body.

float a = this.getWidthScaled()*0.5f/32.0f;
float b = this.getHeightScaled()*0.5f/32.0f;
Vector2[] v = {new Vector2(-a,-b), 
               new Vector2(a,-b),
               new Vector2(a,b),
               new Vector2(-a,b)};
body = PhysicsFactory.createPolygonBody(pWorld, this, v, BodyType.DynamicBody, mFixtureDef);

다른 팁

It's pretty late, but I got around a similar problem using masking

http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/

cheers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top