[Help] Shape's Frictions
Posted: Tue Dec 12, 2017 2:30 pm
Hey guys, i'm a new LOVE user and i've got a problem : frictions didn't work with this code :
I applied to both fixture a friction of 1 but the ball still rolls as if it was on the ice.
Thank you for the help !
Code: Select all
function love.load()
love.window.setMode(800, 600, {resizable=false})
love.physics.setMeter(64)
world = love.physics.newWorld(0, 64*9.81, true)
objects = {}
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 0,550, "static")
objects.ground.shape = love.physics.newRectangleShape(400, 25, 800, 50)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape)
objects.ground.fixture:setFriction(1)
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 400, 300, "dynamic")
objects.ball.shape = love.physics.newCircleShape(100)
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1)
objects.ball.fixture:setRestitution(0.6)
objects.ball.fixture:setFriction(1)
end
function love.update(dt)
world:update(dt)
if love.keyboard.isDown("left") then
objects.ball.body:applyForce(-400, 0)
end
if love.keyboard.isDown("right") then
objects.ball.body:applyForce(400, 0)
end
end
function love.draw()
love.graphics.setColor(255, 0, 0, 100)
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints()))
love.graphics.setColor(255,255,255,80)
love.graphics.circle("line", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius())
end
Thank you for the help !