Page 1 of 1

Understanding Physics

Posted: Fri Mar 20, 2009 5:50 pm
So right now I'm attempting to educate myself on the physics system. So far... weird! I've gotten a few things to work, here and there. Right now I'm trying to specifically educate myself on joints. I think I've figured out the RevoluteJoint (in as much as I can get one body to revolve around another body in a rag-doll fashion). Now I'm trying to get my head around DistanceJoint. Here's what I've come up with so far:

Code: Select all

``````-- Orbit

world = love.physics.newWorld(1000, 1000)

bodyA = love.physics.newBody(world, 500, 500)
bodyB = love.physics.newBody(world, 100, 100)
jointA = love.physics.newDistanceJoint(bodyA, bodyB, 0,0,50,50)
jointA:setLength(100)

shapeA = love.physics.newCircleShape(bodyA, 16)
shapeB = love.physics.newCircleShape(bodyB, 16)

bodyA:setSpin(36)
end

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

function draw()
end
``````
The two orbit each-other beautifully, but I don't really understand how or why. Mostly I'm confused about the two points I set in the DistanceJoint itself. Are those coordinates World Origin or Body Origin? Because when I set them to 500,500,100,1000 then the two points immediately move right to each-other to the outer limit of the distance I set and then... they just stop. But if I set one of them to 0,0 then I get this weird orbital pattern. I'm going to continue playing around with this, but maybe someone can shed some light on this for me?

Re: Understanding Physics

Posted: Fri Mar 20, 2009 10:27 pm
OKAY. So I think I get what's going on here:

MADNESS. So I give up on this and Prismatic Joints. I know Revolute Joints and I'm happy enough about that.

Re: Understanding Physics

Posted: Sat Mar 21, 2009 6:45 pm
RTFM

Meaning, you probably want to read http://box2d.org/manual.html and specifically for joint types take a look at http://box2d.org/manual.html#d0e984

Re: Understanding Physics

Posted: Sat Mar 21, 2009 10:45 pm
Actually I did read that, and it confused me more than anything else... *sigh* I should probably hang up the idea of using physics in my games. Oh well. ON TO THE NEXT THING!

Re: Understanding Physics

Posted: Sun Jun 28, 2009 9:44 pm
Well, don't be too hard with yourself. In this case, the joints implementation is actually broken. So it's quite normal that you couldn't figure it out.

Re: Understanding Physics

Posted: Mon Jun 29, 2009 2:32 am
I've still pretty much abandoned physics in my games for now... Of course I haven't been making a lot of games, lately. Mostly due to having the general buzz that is my brain not putting out anything of any use.