13

I have a body that has a mass of 10, and each cycle of the program I apply a force of 100 to it using the simple approach;

Vector2 force = new Vector2(0, 1) * 100;
bod.ApplyForce(force, bod.GetWorldCenter());

It works great, accelerates and all of that, but once it gets to a velocity of 10 (100 / 10 I assume) it won't go any faster. I am not a physicist by any means, but I do recall that the body should continually accelerate, like it would under gravity. Is this speed limit a result of the way Box2D does things, or am I royally screwing something up ? Also, what do I do to fix it.

NOTE: I get the same limited velocity if I use ApplyLinearImpulse instead of ApplyForce

Update: I am well aware of the overall max speed limit imposed by Box2D (in b2Settings.h). In my example, the item in question is moving well below this limit as changing the appplied force, be it 1000 or 10000 will always come around to the max velocity of (force / mass).

A.R.
  • 15,405
  • 19
  • 77
  • 123
  • This is not a proper answer but maybe you should work with a smaller overall scale. Like this you could apply smaller forces and then wouldn't be stuck by some forces limits. Box2d often doesn't like when you work on a too big scale basis. – phemios Mar 09 '13 at 18:07
  • the scale is fine. an object has a mass of 10kg and I am applying a force of 100Ns to it. The capped speed winds up being 10 m/s which is way way in the scale range for Box2D. – A.R. Mar 10 '13 at 01:55
  • 1
    Have you checked the linear dampening? – Davos555 Mar 14 '13 at 11:47
  • @Davos555 What about it? Your question is vague. – A.R. Mar 14 '13 at 13:11
  • I read something somewhere about limiting top speed using linear dampening, perhaps it is set somewhere and limiting the speed? – Davos555 Mar 14 '13 at 13:12
  • to continue from comment of Davos555, what happens if you stop applying the force? Does it stop or coast forever? – hyde Mar 19 '13 at 11:33
  • It coasts forever. Adding more force or leaving it alone have the same effect. I still haven't been able to look in on the linear damping. – A.R. Mar 19 '13 at 12:45

1 Answers1

4

You're hitting the maximum allowable velocity of an object. There are two ways to fix this:

  1. Adjust the maximum allowable velocity in your Box2D settings; Open up Settings and change the MaxTranslation float/const to a higher value, I'm assuming it's at the default of 2.0.

  2. Scale down your object size, perform the calculations necessary, scale your objects back up. This is the technically correct way of doing it, as Box2D's comments for MaxTranslation note:

The maximum linear velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.

So try #1, and if that does work, then it means that you're likely in need of scaling. Hope that helps.

Mike P.
  • 1,920
  • 1
  • 18
  • 20
  • This answer keeps popping up, and it is wrong. Please read the whole question, in particular the part mentioned 'Update' – A.R. Mar 19 '13 at 19:10
  • Are you sure you're hitting a **velocity** of 10 m/s? Or are you actually hitting 10 meters in distance per time step? Box2D is reporting movement in distance per time steps, so if you assume 60Hz, a given body covering the `MaxTranslation` default of `2.0` units per timestep is actually moving at a velocity of 120 m/s. I don't mean to sound rude, but I think you might be confusing the two. – Mike P. Mar 19 '13 at 19:24
  • yes, I am positive. I am very aware of what you are describing. If I was hitting the limit, then I wouldn't be able to ramp it up as I am describing (with larger forces). – A.R. Mar 19 '13 at 19:28
  • 1 - 5m, well within scope. – A.R. Mar 19 '13 at 19:38
  • 1
    I hit this limit in similar situation - 1m body size, 40m/s velocity. It is really limited by MaxTranslation, so the answer is right. But I don't understand why it hits this limit. – ei-grad Mar 26 '18 at 13:18