[library] bump.lua v3.1.4 - Collision Detection

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by Kingdaro »

kikito wrote:You raise a completely valid concern. I will see what I can do. Thanks

EDIT: Done. I've added two new methods to world:
  • local items, len = world:getItems() is just what you need
  • local count = world:countItems() just returns the number of items
I am releasing v3.1.2 with these changes
Amazing. Thank you based kitito. :awesome:
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by josefnpat »

I just wanted to leave a thank you; I integrated this into Judgement Arena, and it works flawlessly! Thanks so much for writing this library!
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by kikito »

I am glad it is working for you! Thanks for trying my lib ^^
When I write def I mean function.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by josefnpat »

I'm using this library as a spatial partition, and it works brilliantly!

Image
Image
Image
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by kikito »

Hey, that is cool!

Have you tried tweaking the cell size? Your game seems to be relatively sparse (compared to a tile-based game) so playing with the cell size should bring some interesting results. (Remember that you will have to re-create the world and re-insert the ships every time you change the cell size)
When I write def I mean function.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by josefnpat »

kikito wrote:Hey, that is cool!Have you tried tweaking the cell size?
Not too much! I'll have to try it out.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by Fenrir »

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):
Image

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!
Attachments
bump_test.love
(6.86 KiB) Downloaded 117 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by kikito »

Hi there,

I am envious of your art style - it looks very nice!

Thanks for taking the time to prepare a test example. I will investigate this as soon as I can, but please understand that these "right in the border with smaller-than-1-pixel-movement" situations might take some time to resolve. It is usually some < that should be a <=, or floating-point comparison.
When I write def I mean function.
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by Fenrir »

I am envious of your art style - it looks very nice!
Thanks, I'm lucky to work with a very talented artist for this project!
And yes I'm testing with really small values as I'm using an interpolated accelerated speed for the player (thanks to Tween btw :)), and for acceleration I'm using an inQuad interpolation, so it starts very small.

EDIT: And I just made further testings, if you change the offset from 0.05 to 10 in my example the problem is still here, and a lot more visible this time.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: [library] bump.lua v3.1.2 - Collision Detection

Post by Jasoco »

Is it at all possible to somehow integrate circular collision detection (Not necessarily resolution, just detection) into Bump? I don't need to resolve collisions with them or anything (Though I would love to be able to have arbitrary shapes if someone made a simple library like Bump that resolved collisions with them.) but just detect Bump box objects overlapping with circular, and possibly oval shapes. Just for detection.

Expanding on that, maybe detect collisions (But not resolve) with other polygonal shapes.

While Bump's 90º square boxes are great for making the environment, I'd like more options for shapes when it comes to adding in hitboxes for enemies and other things. Like if I wanted to add a circular saw like so many other games have now (They're like crates in 3D games.) with just Bump I'd have to use a bunch of small boxes to create a rudimentary circle or something then move all of them at the same time with the entity when all I really need is to detect if the box is overlapping it.

I mean I guess I could pile HardonCollider on top of Bump and use HC for hitboxes and Bump for platforming. If I had to. I would understand why you wouldn't want to put it in Bump for that very reason.

Thoughts?
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 1 guest