mass?

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
miloguy
Prole
Posts: 32
Joined: Sat Jul 02, 2011 2:09 am

mass?

Post by miloguy »

What should I set mass as for objects? Would it be a bad idea to have everything have the same mass? Should I do like width*height or pi*radius^2? I'm confused :x
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: mass?

Post by BlackBulletIV »

It depends how "weighty" you want your objects feeling. Mass has an effect on how much force you have apply to get the object moving, and on how much force it takes to stop it moving. It really depends on what you're trying to do. But I wouldn't recommend doing something like width * height, that would be VERY heavy (a kilogram per pixel).
User avatar
miloguy
Prole
Posts: 32
Joined: Sat Jul 02, 2011 2:09 am

Re: mass?

Post by miloguy »

I don't really care how much each object weighs, as long as it falls the same speed and moves the same speed
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: mass?

Post by T-Bone »

Why would you need to set a mass? Does love.physics require that?
User avatar
miloguy
Prole
Posts: 32
Joined: Sat Jul 02, 2011 2:09 am

Re: mass?

Post by miloguy »

T-Bone wrote:Why would you need to set a mass? Does love.physics require that?
It does. And if you set the mass to 0 then it doesn't fall.

I'm a simple person, I like anchored or unanchored better :P
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: mass?

Post by BlackBulletIV »

miloguy wrote:I don't really care how much each object weighs, as long as it falls the same speed and moves the same speed
Well, you'll have to experiment with what mass you want each object as. How about something like 20-40? I highly doubt you want a tiny ball to fall like 20 cars glued together.
miloguy wrote:And if you set the mass to 0 then it doesn't fall.
Yeah, 0 mass makes the object static.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: mass?

Post by ivan »

miloguy wrote:And if you set the mass to 0 then it doesn't fall.
That actually makes sense when you think about it: how much force would you need to apply to move a body with a mass of 0? (the equation is Force = Mass * Acceleration)
I don't really care how much each object weighs, as long as it falls the same speed
Box2D works with mass in KG.
The speed at which an object falls is not affected by its mass (although you can slow down falling objects using linear damping - kinda like a dumbed down version of air resistance).
and moves the same speed
It depends on how you move the bodies. If you use SetLinearVelocity then the mass is irrelevant. If you use ApplyForce or ApplyImpulse it is. Keep in mind that a super massive object with a velocity of 10 m/s will produce different collision responses than a less massive object moving at the same speed.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: mass?

Post by ivan »

miloguy wrote:What should I set mass as for objects? Would it be a bad idea to have everything have the same mass? Should I do like width*height or pi*radius^2? I'm confused :x
There's also: http://love2d.org/wiki/Body:setMassFromShapes
However you would need to specify a density for your shapes before using this function in KG/meter^2.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: mass?

Post by Robin »

Body:setMassFromShapes is highly recommended, yes, because it automatically uses the most natural mass for the body. Don't forget to call it after you added the shapes, or it won't work. ;)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests