Box2D Wheel/Revolute Joint not working?

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
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

Box2D Wheel/Revolute Joint not working?

Post 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.
Attachments
test.love
Up - Move Forward
Down - Start Motor
Left/Right - Turn
(1.54 KiB) Downloaded 180 times
Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests