Page 7 of 8

Re: bump.lua - minimal collision detection lib

Posted: Sun Aug 11, 2013 8:34 am
by kikito
tilmah wrote:Any suggestions would be appreciated.
Hi, I don't have any particular suggestion, I have never used ATL yet. Good luck!
tilmah wrote:p.s. Why do you have 't' and 'l' in Bump instead of 'x' and 'y'? What do they stand for?
t,l,w,h => top, left, width, height. I don't call them x and y because sometimes I also need the right and bottom (r and b) and it is weird to have x,r, y,b.

Re: bump.lua - minimal collision detection lib

Posted: Tue Aug 13, 2013 3:44 pm
by Ranguna259
Found a typical collision bug on your demo, dunno if it's just in the demo and I can't really explain it so do this:
Set fly to true.
Go up intil you colide into another object (no the walls, it has to be one of the rectangles).
Once you are coliding go slowly to the left or to the right.
You'll notice the you'll get teleported to the side of the coliding object before ending the colision.

Re: bump.lua - minimal collision detection lib

Posted: Tue Aug 13, 2013 4:15 pm
by vrld
That's very likely a bug in your collision response, not in bump.

Re: bump.lua - minimal collision detection lib

Posted: Tue Aug 13, 2013 4:57 pm
by kikito
Sometimes bump "jumps". It is good, but it is not perfect. The demo does a very simplistic collision response, too. You might see a "jump" here or there, I'm afraid. It was the best I could do in 2-3 months; you should not see them very often.

Collision detection is quite tricky ^^

Re: bump.lua - minimal collision detection lib

Posted: Tue Aug 13, 2013 5:16 pm
by Ranguna259
Indeed, it can be tricky and really glitchy, I'm still trying to code collision for my game and till now I've complitly recoded my player.lua two times and I think I'm going for the third.. But this time I'm gonna use HC, I hope it works out

Re: bump.lua - minimal collision detection lib

Posted: Fri Jul 31, 2015 10:33 pm
by farzher
How do I "bump" another object?

I'm trying to push other players by jumping or running into them.
Is there any support for that? Or does anyone have any tips/snippets?

I tried quickly but it's pretty screwy. So I decided to ask here before I mess with it for hours.

When looping through cols, does it make sense to call world:move on the player I bump into to push them?
But then wouldn't they have to loop through their cols from that push and push anyone else they just bumped into? Sounds like a mess and potential infinite loop?

Re: bump.lua - minimal collision detection lib

Posted: Sat Aug 01, 2015 4:08 pm
by kikito
I am on my mobile so I can't write a lot.

The simplest way to move other characters around is by changing their velocity. The explosions do this in the demo. You can modify the velocity of one object when resolving the cols of another (provided that you handle velocity nicely, not resetting it manually on each frame)

Moving other items "as you move", like pushing a block in zelda, is trickier. You must move the other object the exact amount. Too littke and you will tunnel through it. Too far and it will be separated, not touching any more.

There is an example of this in the "platforms" branch on github. The platforms move the player "just the right amount". Have a look at platform.lua (sorry I can't link it)

Re: bump.lua - minimal collision detection lib

Posted: Wed Sep 23, 2015 6:13 pm
by Sarcose
I'm trying to think about how one would utilize multiple bump worlds to create background and foreground collision layers, and a player that can move between them. Would it be best to have a player hitbox in each layer and just control the one in the active layer, making the appropriate changes with update when switching?

My specific idea is to achieve a 'kinda-3D' ish world in an otherwise traditional sidescrolling platformer, where the player can jump to fore- and backgrounds either arbitrarily or at specific points (if arbitrary movement proves too complex). There will be npcs on these layers, too, moving around and, say, shooting arrows at the player on other layers.

Re: bump.lua - minimal collision detection lib

Posted: Wed Sep 23, 2015 6:37 pm
by s-ol
Sarcose wrote:I'm trying to think about how one would utilize multiple bump worlds to create background and foreground collision layers, and a player that can move between them. Would it be best to have a player hitbox in each layer and just control the one in the active layer, making the appropriate changes with update when switching?

My specific idea is to achieve a 'kinda-3D' ish world in an otherwise traditional sidescrolling platformer, where the player can jump to fore- and backgrounds either arbitrarily or at specific points (if arbitrary movement proves too complex). There will be npcs on these layers, too, moving around and, say, shooting arrows at the player on other layers.
I would just put them all in the same world and have one player but change the "filter" value depending on the 2.5D position. For example like this:

Code: Select all

world:move(self, newx, newy, function (other) 
  if other.layer == self.layer then
    return "slide" -- slide along obstacles
  else
    return nil -- do not collide with other objects
  end
end)
Of course you will probably have to put a bit more logic in there for other types of things (like powerups, coins etc, you probably don't want to "slide" along those)

Re: bump.lua - minimal collision detection lib

Posted: Wed Sep 23, 2015 9:02 pm
by kikito
Both options can work. Either "1 world per slice" or "everything in one world, and filter by slice". The former will probably be slightly more efficient, but also probably more difficult to work with.

Also, please use the following thread to talk about bump, this one is about a previous version:

viewtopic.php?f=5&t=79223