BUG: applyForce() seems to work like applyLinearImpulse()

After playing with it some more, I believe that the applyForce() seems to work like applyLinearImpulse() with a different force/impulse scale.

What I expect is that applyForce() exerts a constant force over time on an object, very much like gravity.
What I observe is that there is no force on the object after the jolt it gets in the beginning.

I’d appreciate a confirmation of my finding or an alternative explanation.

Thanks, Frank.
[import]uid: 8093 topic_id: 1956 reply_id: 301956[/import]

It’s not a bug, but you are essentially correct!

The applyImpulse() methods in Box2D are for cases like suddenly punching an object: the object’s velocity is immediately changed.

The applyForce() methods work over time, but you have to apply them continuously to get the desired change. The amount of force you specify will be applied over one second, assuming you call applyForce() repeatedly on an enterFrame event for the full second. In other words, you should get smooth acceleration during the entire time the force is applied. [import]uid: 3007 topic_id: 1956 reply_id: 5884[/import]

Right - repeatedly calling body:applyForce thru a enterFrame event handler shows the expected behavior - right now looking at two balls circling around each other as planets - cool!

That solves my issue, but a major bug remains… in the documentation!
Please update the documentation of body:applyForce to reflect the proper usage of this function.
(“https://developer.anscamobile.com/content/game-edition-physics-bodies”)

I haven’t tried it out, but I expect the same usage pattern to hold for body:applyTorque (?)

Thanks, Frank. [import]uid: 8093 topic_id: 1956 reply_id: 5907[/import]

Docs updated:

http://developer.anscamobile.com/content/game-edition-physics-bodies#Force_vs._Impulse [import]uid: 3007 topic_id: 1956 reply_id: 6423[/import]

FrankS, any chance of seeing that code, please?

Cheers,

Matt [import]uid: 8271 topic_id: 1956 reply_id: 6509[/import]

http://gist.github.com/594021
– Corona Game SDK example of how to let two bodies circle each other by applying a continuous, attracting force

– The example uses the physics engine, sets gravity to 0, creates two balls separated in the x-direction,
– with initial speeds in opposite y-direction.
– Thru an enterFrame event handler, an attracting force is continuously applied to both balls with body:applyForce().
– The force is normalized over the distance between the two balls
– By playing with the initial speed and force factors, you can make the balls spin faster/slower in circles or ellipses

– Save this file as “main.lua” in a project directory and load it in the simulator

– Enjoy, Frank (September 23, 2010).
… [import]uid: 8093 topic_id: 1956 reply_id: 6534[/import]