문제

I would like to apply a force to a body in jbox2d. I can apply the force on the mass center of the body, there is no problem. However, I need to apply the force to one meter above of the mass center as in the below figure.

enter image description here

I use the below codes but it doesn't work. They only changes the force direction. Isn't it correct method?

Vec2 mCenter = b2_balon.getWorldCenter();
mCenter.y -= 1;
b2_balon.applyForce(new Vec2(1 ,0), mCenter);

Platform: Android, Java and Jbox2d

도움이 되었습니까?

해결책

I found the answer,

Vec2 nokta = b2_balon.getWorldPoint(new Vec2(0, 1));    
b2_balon.applyForce(new Vec2(1 ,0), nokta);

However, I still wonder why the other method doesn't work. Maybe, iforce2d knows because I found the solution at http://www.iforce2d.net/b2dtut/forces link. Thanks iforce2d :).

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