Fast moving objects in love.physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Tabasco
Citizen
Posts: 72
Joined: Tue Dec 02, 2008 5:04 pm

Fast moving objects in love.physics

Post by Tabasco »

I'm trying to make a sort of bullet (cannon ball) using love.physics and I can't motivate the thing to move past a certain speed.
No matter how much force I apply or velocity, it reaches a cap.
Is this a limitation in box2d or is it being capped elsewhere?

Code: Select all

   rock = love.graphics.newImage("rock.png")
   rock_body = love.physics.newBody(world, 200, 200)
   rock_shape = love.physics.newCircleShape(rock_body, 20)
   rock_body:setMassFromShapes()
   --rock_body:setMass(20, 20, 3, 3)
   --rock_body:setBullet(true)
Then

Code: Select all

   rock_body:setVelocity(5000, 0)
I've also tried using states so that it applies a similar impulse or force so long as a key is held down, but the result is the same.
The best result I've gotten so far is passing an inflated delta to world:update()

Am I just doing something wrong or what?
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Fast moving objects in love.physics

Post by osuf oboys »

Tabasco wrote:I'm trying to make a sort of bullet (cannon ball) using love.physics and I can't motivate the thing to move past a certain speed.
No matter how much force I apply or velocity, it reaches a cap.
Is this a limitation in box2d or is it being capped elsewhere?

Code: Select all

   rock = love.graphics.newImage("rock.png")
   rock_body = love.physics.newBody(world, 200, 200)
   rock_shape = love.physics.newCircleShape(rock_body, 20)
   rock_body:setMassFromShapes()
   --rock_body:setMass(20, 20, 3, 3)
   --rock_body:setBullet(true)
Then

Code: Select all

   rock_body:setVelocity(5000, 0)
I've also tried using states so that it applies a similar impulse or force so long as a key is held down, but the result is the same.
The best result I've gotten so far is passing an inflated delta to world:update()

Am I just doing something wrong or what?
I don't know if it really is a limitation but I have interpreted it as one. To circumvent it, update the world faster than real time, e.g. world:update(10 * dt).
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
Tabasco
Citizen
Posts: 72
Joined: Tue Dec 02, 2008 5:04 pm

Re: Fast moving objects in love.physics

Post by Tabasco »

The best result I've gotten so far is passing an inflated delta to world:update()
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Fast moving objects in love.physics

Post by osuf oboys »

Tabasco wrote:
The best result I've gotten so far is passing an inflated delta to world:update()
Alright, I'm sorry.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Fast moving objects in love.physics

Post by rude »

That's weird. It has to be some sort of LÖVE-bug[1]. I've seen objects move much faster than that in the official Box2D demos.

[1]: http://en.wikipedia.org/wiki/Love_bug

EDIT:

Code: Select all

/// b2Settings.h (part of Box2D)
/// 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.
#ifdef TARGET_FLOAT32_IS_FIXED
const float32 b2_maxLinearVelocity = 100.0f;
#else
const float32 b2_maxLinearVelocity = 200.0f;
const float32 b2_maxLinearVelocitySquared = b2_maxLinearVelocity * b2_maxLinearVelocity;
#endif
Seems like it's a Box2D limitation, however it is because of LÖVE that it appears to be too slow. See this thread. I plan to scale everything by 1/80, which means (for instance) that the range 0px-800px will internally be 0.0f-10.0f. Right now, the range 0px-800px is 0.0f-800.0f, and therein lies the problem.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests