Page 1 of 1

Box2D Wheel/Revolute Joint not working?

Posted: Mon Jul 01, 2013 8:13 pm
by severedskullz
Hello,

I have been messing around with Box2D for some top down physics and I have most of it working, however I cannot seem to get Revolute or Wheel joints working. When I tried wheel joints, they would not attach to my parent body. Instead of fighting with that I simply changed the word Wheel to Revolute and it attached fine when creating the Revolute joint. Now I am attempting to get the motor working but I am unable to do so. I cannot seem to find any tutorials up on the wiki to demonstrate any correct ways of doing this so I really don't know what else to do.

Code: Select all

function createTank(world, x,y,sX,sY)
	local tank = {}
	tank.chassis = {}
	tank.chassis.body = love.physics.newBody(world,x,y,"dynamic")
	tank.chassis.shape = love.physics.newRectangleShape(sX, sY)
	tank.chassis.fixture = love.physics.newFixture(tank.chassis.body, tank.chassis.shape, 1)
	tank.chassis.fixture:setRestitution(0.1)
	
	tank.turret = {}
	tank.turret.body = love.physics.newBody(world,x,y,"dynamic")
	tank.turret.shape = love.physics.newRectangleShape(64, 16)
	tank.turret.fixture = love.physics.newFixture(tank.turret.body, tank.turret.shape, 1)
	
	tank.turret.joint = love.physics.newRevoluteJoint( tank.chassis.body, tank.turret.body, x, y, false )
	tank.turret.joint:enableMotor(true)
	tank.turret.joint:setMaxMotorTorque(1000) -- Just for shits and giggles? Why isnt this working
	tank.turret.joint:setMotorSpeed(50)
	return tank
end
Code is shit because it is just a test of functionality at this point.