Page 1 of 1
Fast moving objects in love.physics
Posted: Wed Jan 14, 2009 6:23 pm
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
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?
Re: Fast moving objects in love.physics
Posted: Thu Jan 29, 2009 7:10 pm
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
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).
Re: Fast moving objects in love.physics
Posted: Thu Jan 29, 2009 8:05 pm
by Tabasco
The best result I've gotten so far is passing an inflated delta to world:update()
Re: Fast moving objects in love.physics
Posted: Thu Jan 29, 2009 8:46 pm
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.
Re: Fast moving objects in love.physics
Posted: Fri Jan 30, 2009 8:39 am
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.