ApplyForce works over gravity?

Topics: User Forum
Aug 31, 2012 at 2:34 PM

I've set up my world, added in a few obstacles and of course my player, but apply force is being a tad broken.
applying a higher force does not make it happen faster or with more force, it simple emphasises that direction over others, doing so also overpowers gravity if strong enough!?
this is very broken in that if you push something to the right while its falling, it wont stop falling, it'll just be falling with some movement to the right!

Why does apply force not apply force but instead change force?
I'm completely confused by this.

If any of you need code, I've messed with a bunch of numbers high and low,
I set up the world as normal, the step time delta I use XNA's elapsed milliseconds, I've also tried accumulating force to apply at the end of the update as well as applying as I go along, both having the same effect. 

Aug 31, 2012 at 6:30 PM

If you are falling and I push you a bit to the right would you stop falling?

Gravity is handled by the engine in a slightly special way as it is applied automatically to all dynamic objects. If you don't need it you can set up the world without it (pass Vector2.Zero to the constructor). You can then apply your own gravity only when you need it by using ApplyForce() or ApplyLinearImpulse(). Or the other way round - you can also cancel gravity for a body by applying an equal and opposite impulse each time step to the body as per Newton's first law of motion.

Aug 31, 2012 at 7:00 PM

I'm not saying thats what should happen, I'm saying thats whats happening,
I apply force to the right or left while falling and the object starts falling slower, which is obviously not right.
I do want gravity, this is for a platformer game, I'm simply saying, when I use applyforce for a horizontal force gravity seems to be applied less.

Aug 31, 2012 at 8:01 PM

Is applyforce needed? Have you tried applyLinearImpulse?

Aug 31, 2012 at 8:10 PM

apply force is preferred the character in the game is a slimey slippery ball of goo, I'd like it to speed up, slow down and change direction smoothly. applylinearimpulse did not work when I tried using it for jumping, it did nothing at all, though it did do something when I changed the timing to below 1 so that may be the issue there. but regardless of timing applyforce still did not apply extra force with higher numbers.

Aug 31, 2012 at 9:37 PM

Gravity is applied in Island.cs:Solve() lines 119-120. As you can see it's a constant acceleration. What you say that it is applied less due to external forces is impossible. There must be some other issues. It would help if you post some code, preferably as a self-contained Testbed case to see your body masses and how you apply forces.

Coordinator
Sep 9, 2012 at 11:08 PM
PushBombshell wrote:

applylinearimpulse did not work when I tried using it for jumping, it did nothing at all, though it did do something when I changed the timing to below 1 so that may be the issue there. but regardless of timing applyforce still did not apply extra force with higher numbers.

^^ That leads me to believe that you are not scaling your units to meters. A linear impulse of 30 in the Y direction should cause your character to jump a considerable amount. Are you using pixel to meter conversions?