Hi guys,
First of all I would like to say that bump is an amazing library, collisions in my new project are entirely based on it and it works great! But I'm having a strange issue and I'm not sure where it comes from.
Here is what happens (but quite rarely to be honest):
=> I resolve a collision between my player and a wall, bump returns me a position and I update my player position to it (it should be against the wall).
=> Then I keep the same velocity and I try to solve a collision from my new position, but bump tells me there's no collision, and I update my player position.
=> I continue to test my collisions with the same velocity, and this time bump tells me that I have a collision and send me back to the initial position it sent me at step 1.
=> And so on, one test will tell me that I've no collisions and the next one it will send me back at my initial position, making my player to move a bit.
Visually, here's the result (the issue is visible on the left wall, the right one works without problem):
I tracked it down to a simple example (love file attached):
Code: Select all
local bump = require "bump"
--
local world
local player = { name = "Player", x = -638.37210358366, y = 121.258009477, width = 45, height = 230 }
local wall = { name = "Wall", x = -836.50049554579, y = 9.28935041878, width = 198.12839196213, height = 406.74931778108 }
--
-- LOVE callbacks
--
function love.load(arg)
world = bump.newWorld()
world:add(player, player.x, player.y, player.width, player.height)
world:add(wall, wall.x, wall.y, wall.width, wall.height)
end
function love.draw()
love.graphics.translate(1200, 0)
love.graphics.scale(1.2, 1.2)
love.graphics.setColor({ 0, 255, 0, 150 })
love.graphics.rectangle("fill", player.x, player.y, player.width, player.height)
love.graphics.setColor({ 255, 0, 0, 150 })
love.graphics.rectangle("fill", wall.x, wall.y, wall.width, wall.height)
end
function love.update(dt)
local actualX, actualY, cols, len = world:move(player, player.x - 0.05, player.y)
player.x = actualX
player.y = actualY
print("actualX="..actualX..", actualY="..actualY)
print(len)
end
When running it, you'll see that on one frame you'll get a collision, then the next one no collisions, and so on. And moving a bit the wall solve it (bump always detects a collision).
Am I doing something wrong?
Thanks for your help!