BUMP collision help

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
Joelrodiel
Prole
Posts: 27
Joined: Wed Apr 20, 2016 3:40 am

BUMP collision help

Post by Joelrodiel »

I recently started using BUMP as my collision library after giving up on trying to make collisions myself. So far everything is smooth until I wanted to change the type of collision. I cannot understand how to change the collision of certain objects when it collides with other certain objects. EX: Player collides with wall, but passes coin. How can I do this? I know there's a way, and Vive tried it, its like a weird local function:

Code: Select all

local playerFilter = function(item, other)
  if     other.isCoin   then return 'cross'
  elseif other.isWall   then return 'slide'
  elseif other.isExit   then return 'touch'
  elseif other.isSpring then return 'bounce'
  end
  -- else return nil
end
But I have not been able to use it on any of my code, it just wont work. I wrote some program that uses BUMP and IM trying to implement it. Any help would be greatly appreciated.
Attachments
demo.love
(8.51 KiB) Downloaded 62 times
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: BUMP collision help

Post by Azhukar »

There's a detailed explanation on how to do this exact thing on the projects github page https://github.com/kikito/bump.lua#movi ... resolution

It's a function you pass to world:move, the function arguments are the 2 colliding entities. In the example filter you posted, you would move your player by calling

Code: Select all

world:move(playerTable, goalX, goalY, playerFilter)
In the example filter function, argument 'other' would become what player collides with. Your tables for the objects would then need to be similar to the following:

Code: Select all

mycoin = {isCoin = true}
mywall = {isWall = true}
myexitarea = {isExit = true}
myspring = {isSpring = true}
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 47 guests