I noticed if I make my player run fast enough and his bullets slow enough he can crash into his own bullets and they get stuck to him. I thought I was supposed to use the :filter function to ignore that. I used the code from the Bump demo as follows but it doesn't ignore the player as parent of the bullet object. This is the code I have in the bullet object:
function Bullet:filter(other)
local kind = other.class.name
if kind == 'Block'
or kind == 'Enemy'
or (kind == 'Player' and not self.ignoresParent)
then
return "slide"
end
end
"slide" is used if you want one object to NOT pass through another, but move along it. Like if you have a character run into a wall. If you want a bullet to pass through other objects, you'll want to use "cross" instead.
That said, if you want the bullet to completely ignore the player (like, a player shouldn't be able to shoot themselves), then you'd return nil instead of any of the other collision types.
for i=1, len do
local col = cols[1]
local other = col.other
local kind = other.class.name
if kind == 'Enemy' or kind == 'Lava' then
self:damageItem(other)
elseif kind == 'Player' then
return nil
end
end
This doesn't seem to work though.
I tried changing the filter to cross too but it didn't do anything. The bullets still get stopped by the player and either attach to him or end up being taken along with him.
function Bullet:filter(other)
local kind = other.class.name
if kind == 'Block'
or kind == 'Enemy'
or (kind == 'Player' and not self.ignoresParent)
then
return "cross"
end
end
Everything else seems to work fine. The bullets damage and kill the enemy etc. With returning 'cross' or nil the player still stops the bullet in its path.
You'll have to post the code that's using the filter then (whatever is calling Bump:move()). The problem is probably in there somewhere. Or your entire .love project if it suits you.