1

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

adba
  • 477
  • 9
  • 25
  • 1
    It looks fine to me. Try it with a much larger offset than 1, so you can more clearly see the difference. – iforce2d May 04 '14 at 01:23
  • @iforce2d do you know why the written code above doesn't work? While the above code works. – adba May 10 '14 at 12:42

1 Answers1

0

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

adba
  • 477
  • 9
  • 25
  • As long as you are applying the force at an offset to the center of mass, the body should spin around. Both of these methods should cause it to spin around. Is that what you were trying to do? I think you should explain your goal in more detail. The phrase "doesn't work" should really be banned on Stack Overflow :) – iforce2d May 10 '14 at 14:18
  • In the first method, the body doesn't spin around. I cannot exactly understand what it does but I guess it goes linearly to the direction of sum of "force" and "point" vectors, without spinning around. – adba May 10 '14 at 14:51