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

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

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

@joedono:

Found the problem. It was a faulty implementation of "cross". It was not supposed to "move the item around", but it was moving it when doing the collision resolution. In your case it would mean that the item was "pushed away by the blocks" until it stopped colliding with them (that's why you got those straight lines).

I have fixed the bug and released 3.0.1. If you redownload it again from github, it should work now.

Again, thanks for your help resolving this.
When I write def I mean function.

joedono
Prole
Posts: 40
Joined: Mon Mar 04, 2013 6:58 pm

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

Super cool! Glad to help. Going to be using this in my next project.

Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

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

hey kikito, how can i get item colliding instead of other?
i keep all my entities in a table, because of that my filter function changes the values of all the items in the entity table instead of just that one that is colliding
"This is what videogames should be like; they should have meaning and triple machine guns"
- Jan Willem Nijman, 2013﻿
github

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

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

Doctory wrote:hey kikito, how can i get item colliding instead of other?
i keep all my entities in a table, because of that my filter function changes the values of all the items in the entity table instead of just that one that is colliding
Hi there,

You can see an example of this in the grenades of simpledemo. Each grenade has its own filter, so the filter can reference "self" (the grenade).

So if you need to use "item" in the filter itself, you have to create a separate filter for each entity that needs it. This usually means that you'll create the filter when you create the entity itself.

The reason why filter can not depend on item is kind of complicated. In short, it is this: the detection phase uses 4 coordinates which change gradually while the resolution happens - but this must be done without changing the coordinates of the item being collided. So the item is never passed around.

I realize that it is a bit weird not having the item there somewhere. I will see if I can find a way to put it as an extra parameter, but I can make no promises on that.
When I write def I mean function.

Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

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

ah, thanks.
"This is what videogames should be like; they should have meaning and triple machine guns"
- Jan Willem Nijman, 2013﻿
github

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

How exactly would one make a moving platform? i.e. one that a player or other character would stand on, and move with it, but retain the ability to walk and jump off of it.

I have horizontally moving ones working fine it seems. (Well not really. The platform moves one frame before the player moves so they're always out of sync.) But vertical ones don't work. Not sure exactly how to tackle it.

s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Jasoco wrote:How exactly would one make a moving platform? i.e. one that a player or other character would stand on, and move with it, but retain the ability to walk and jump off of it.

I have horizontally moving ones working fine it seems. (Well not really. The platform moves one frame before the player moves so they're always out of sync.) But vertical ones don't work. Not sure exactly how to tackle it.
When doing player collision, check all things colliding with the foot "mesh" for being platforms, then store the player in "platform.players" or the platform in "player.standingOn", then in platform:update or player:update, whichever gets updated first in your update loop, move or be moved correspondingly?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
baby:hurt(me)
end

s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Jasoco wrote:How exactly would one make a moving platform? i.e. one that a player or other character would stand on, and move with it, but retain the ability to walk and jump off of it.

I have horizontally moving ones working fine it seems. (Well not really. The platform moves one frame before the player moves so they're always out of sync.) But vertical ones don't work. Not sure exactly how to tackle it.
When doing player collision, check all things colliding with the foot "mesh" for being platforms, then store the player in "platform.players" or the platform in "player.standingOn", then in platform:update or player:update, whichever gets updated first in your update loop, move or be moved correspondingly?
And ofc just set y pos... when the player jumps you could add the platform to an ignore list for a few frames just in case.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
baby:hurt(me)
end

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

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

Hi there,

I would do them like this:

Update the platforms before updating the player (that makes things a bit easier).

When a player collides with a platform:
• If the collision normal is not "up", do a normal collision (I assume that pass-through platforms are properly filtered)
• If the collision is "up", then displace the player with dx = platform.vx * dt, and dy = platform.vy * dt
I think that should do it.

I will try to do an example tomorrow - today I am a bit busy I'm afraid.
When I write def I mean function.

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

No problem. If you want me to provide my current code I can. I've ported it mostly to 3.0 and it is back to working just like it was pretty much. I'll keep playing around. I have some ideas. I just want to make sure I do it properly.

Edit: I did it! At least it looks like I did.

Basically I made a separate callback in the player object called "moveWithPlatform" that accepts the vx and vy of the platform. When the player is standing on a platform it gets a "attachedToPlatform" string that refers to the platform in question. Then in that platform's object, it checks to see if the player is attached to it and if so it calls the "moveWithPlatform" callback for the player which uses Bump's collision callbacks to make sure it handles collisions the same way the player would by itself.

I will modify it to also move other stuff standing on it too.

### Who is online

Users browsing this forum: No registered users and 8 guests