## Understanding Physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

### Understanding Physics

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?
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!

Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

### Re: Understanding Physics

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.
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!

Zett
Prole
Posts: 1
Joined: Sat Mar 21, 2009 6:42 pm

### Re: Understanding Physics

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

Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

### Re: Understanding Physics

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!
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!

Tenoch
Citizen
Posts: 76
Joined: Mon Jul 21, 2008 7:49 am

### Re: Understanding Physics

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.
"When in doubt, use brute force." Ken Thompson

Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

### Re: Understanding Physics

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.
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!

### Who is online

Users browsing this forum: Geecko, Google [Bot] and 3 guests