Pergunta

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

Foi útil?

Solução

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 :).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top