Page 1 of 1

Rigid Body physics

Posted: Tue Nov 01, 2011 2:43 am
by frank_lloyd_wrong
I have recently begun using love, and I'm loving it!
My question: How do you get rigid body physics to work? I am familiar with the basics of physics - creating bodies, attaching shapes, applying forces, etc.

However, as of right now none of my objects will topple or rotate - they simply move and bounce held up right.

I have searched extensively, but there seems to be little information about love beyond the wiki and the api.
Does the engine allow this, and does it have it on by default? Or should it already be acting correctly?
If I need to explicitly turn this behavior on, what calls do I need to make? There is nothing obvious in the api that suggests that it would turn this on. If the engine does not support this, what recourse do I have to implement it myself?

Thank you to anyone who responds.

Re: Rigid Body physics

Posted: Tue Nov 01, 2011 4:45 am
by ivan
Love uses a wrapped version of http://box2d.org/
Bodies have a property called "fixedRotation" which defines if they should rotate or remain "axis aligned"

Re: Rigid Body physics

Posted: Tue Nov 01, 2011 7:01 am
by Robin
Objects only rotate when their rotational inertia is something other than zero. It is the last argument to love.physics.newBody.

Re: Rigid Body physics

Posted: Tue Nov 01, 2011 10:50 am
by felix24
after you have defined your body and shapes you can use:

Code: Select all

yourBody:setMassFromShapes( )
this will set the mass, rotational inertia etc for you based on the shapes attached to the body. It's quite handy.
Here's the wiki page:

http://love2d.org/wiki/Body:setMassFromShapes

Re: Rigid Body physics

Posted: Thu Nov 03, 2011 4:00 am
by frank_lloyd_wrong
Thank you so much! It now works well.