[Physics] Applying Force Constantly - Gravity?

Hi all,

I’m really not an expert on physics engine in general so I hope I’m missing something obvious.

I have scenario where I have to simulate a vehicle driven on a surface that climbs up and down. I’ve been playing around with the physics API but the only way I could apply contant force to the non-static body was through Gravity. body:applyForce or body:applyLinearImpulse( ) didn’t help as their application is instantaneous. I’ve also tried to frequently apply force using body:applyForce (something like every 50ms) but the result was a constantly flipping vehicle :slight_smile: or a static one because it couldn’t climb a hill.

So, if you could point me to the right direction with regards to what I’m trying to achieve it would be greatly appreciated.

Thanks. [import]uid: 96271 topic_id: 18090 reply_id: 318090[/import]

Hm… Have you any Screenshots?
Why not using the traditional attempt and move the objects in an enterFrame? [import]uid: 13097 topic_id: 18090 reply_id: 69182[/import]

Thanks for the prompt suggestion. But, if I’m not mistaken, this mean that the path should be well known. In this case, I’d rather not deal with that. Am I missing something? [import]uid: 96271 topic_id: 18090 reply_id: 69184[/import]

Ahh. I guess now I get your Problem. So you want a 2D SideScroller where you have hills and a car (let’s say like tinywings or BikeBaron (just without the 3D)).

If that’s the case, I would suggest using body:applyLinearImpulse( ).
Then you can apply a linear impulse in the direction the car is facing atm!
Just put the body:applyLinearImpulse( ) into the enterframe and use very low values! [import]uid: 13097 topic_id: 18090 reply_id: 69186[/import]

Hmm… I’ll give it a try with low values. I’m also planning to increase the friction of the ground for the downhill run so that the vehicle won’t pick up too much speed.

Thanks :wink: [import]uid: 96271 topic_id: 18090 reply_id: 69225[/import]