Max velocity = 200, why?

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.
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Max velocity = 200, why?

Post by Almost »

Huh. I'm trying to use love's physics, but I just discovered that any velocity numbers > than 200 are chopped down to 200. I don't know why, I just know that they are. And that it's annoying. Moving faster than 200 is a must.

Here's a love file that demonstrates this cropping velocity down to 200. If I'm missing something, please tell me now.
Attachments
velocityFAIL.love
(651 Bytes) Downloaded 293 times
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Re: Max velocity = 200, why?

Post by Almost »

Huh, also: love crashes if a world has 2000 or more physics objects. (actually, I think it's 2048)
Last edited by Almost on Sun Sep 06, 2009 3:42 am, edited 3 times in total.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Max velocity = 200, why?

Post by osgeld »

whats the objects mass?
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Re: Max velocity = 200, why?

Post by Almost »

Re: Osgeld
the mass is 1, but that shouldn't matter to setVelocity()
User avatar
Boder
Prole
Posts: 7
Joined: Thu Aug 27, 2009 5:47 pm

Re: Max velocity = 200, why?

Post by Boder »

It looks like the 200 m/s limit is a feature of the underlying "Box2D" so you have to scale your simulation to within the limits.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Max velocity = 200, why?

Post by osgeld »

Code: Select all

function update(dt)
    world:update(X * dt)
end
Attachments
main.lua
(190 Bytes) Downloaded 283 times
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Re: Max velocity = 200, why?

Post by Almost »

doh, that is a clever fix. I still have issues with 2000+ physics objects though.. I guess I'll just have to have fewer objects..
Last edited by Almost on Sun Sep 06, 2009 5:43 am, edited 1 time in total.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Max velocity = 200, why?

Post by osgeld »

you can have smaller physical worlds, depending on your need for accuracy and scale to shown perspectives, its all a matter of scale

PS: just cause I was bored ....

Code: Select all

function load()
	love.graphics.setFont(love.default_font,12)

	world = love.physics.newWorld(1000,1000)
	body  = {}

	for i = 1, 6 do
		table.insert(body, love.physics.newBody(world,100,(i *100)))
	end
		
	for i = 1, #body do
		body[i]:setVelocity((5 * i),0)
	end
end

function update(dt)
	world:update(50 *dt)
end

function keypressed(key)
	if key == love.key_r then 
		world = nil
		body  = nil
		collectgarbage("collect")
		load()		
	end
end

function draw()
	for i = 1, #body do
		local x, y = body[i]:getPosition()
		love.graphics.circle(love.draw_fill,x,y,10)
		love.graphics.draw('Expected Speed: ' .. (i * 5) ,10,y-15)
		love.graphics.draw('Actual Speed: ' .. body[i]:getVelocity() ,10,y)
	end
	
	love.graphics.draw('R to restart',10,10)
end
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Max velocity = 200, why?

Post by rude »

From b2Settings.h:

Code: Select all

/// 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.
const float32 b2_maxLinearVelocity = 200.0f;
This limit is very large if you use Box2D as it's intended. In LÖVE 0.5.0, one meter is 1px (not good). In LÖVE 0.6.0 you can set how many pixels one meter should be.

Also b2Settings.h:

Code: Select all

const int32 b2_maxProxies = 2048;
That's the limit of how many shapes you can have.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Max velocity = 200, why?

Post by Robin »

rude wrote:In LÖVE 0.5.0, one meter is 1px (not good)
You can change that with CAMERAs. That's how we did it in LovelyBigPlanet.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 5 guests