Rigid Body 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
frank_lloyd_wrong
Prole
Posts: 2
Joined: Tue Nov 01, 2011 12:32 am

Rigid Body physics

Post 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.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Rigid Body physics

Post 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"
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Rigid Body physics

Post by Robin »

Objects only rotate when their rotational inertia is something other than zero. It is the last argument to love.physics.newBody.
Help us help you: attach a .love.
User avatar
felix24
Party member
Posts: 163
Joined: Tue Jul 26, 2011 4:51 pm
Contact:

Re: Rigid Body physics

Post 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
frank_lloyd_wrong
Prole
Posts: 2
Joined: Tue Nov 01, 2011 12:32 am

Re: Rigid Body physics

Post by frank_lloyd_wrong »

Thank you so much! It now works well.
Post Reply

Who is online

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