Page 1 of 1

Collision detection with no response

Posted: Tue Mar 15, 2011 12:19 pm
by thib
Hello,

I am quite new with love2D, and am creating a small game using the physic module.

Is it possible to know if two shapes are colliding but not apllying any collision effects to these shapes.

For example, I have 2 ball (A & B ) moving. When they collide. I want to be able to destroy ball A, but having no effect on ball B trajectory.

If possible I would like to avoid using a different collision system like hardoncollider.


Thank you in advance.

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 1:50 pm
by bartbes
You're looking for sensors.

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 3:12 pm
by thib
I think this is exactly what I was looking for. Thank you very much!

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 3:36 pm
by thib
I tried, and it worked :)

But I had a small problem : it seems that setting this attribute take only effect at the next frame. So if when I create the ball, it is immediatly colliding with the other ball, there is a physical response.

To fix it I set a mask for one frame, but It is not really good, because I finnaly have to wait 2 frame before beeing able to handle the collision (1 for unsetting the mask and 1 for getting the collision callback)

Did I missed something or maybe a bug with Löve ?

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 4:00 pm
by tentus
Destroying physics objects is kind of an odd thing in Love: as far as the community has been informed, you shouldn't do it, ever, because it leads to crashes. https://bitbucket.org/rude/love/issue/1 ... -not-crash http://love2d.org/forums/viewtopic.php?f=4&t=2565 Try masking it out instead, that's the semi-official response.

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 4:06 pm
by bartbes
@tentus: He's not trying to destroy it..

Anyway, what about running world:update(0)?

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 4:47 pm
by kikito
bartbes wrote:@tentus: He's not trying to destroy it..
I think he is:
thib wrote:For example, I have 2 ball (A & B ) moving. When they collide. I want to be able to destroy ball A, but having no effect on ball B trajectory.

Re: Collision detection with no response

Posted: Tue Mar 15, 2011 5:05 pm
by thib
kikito wrote:
bartbes wrote:@tentus: He's not trying to destroy it..
I think he is:
thib wrote:For example, I have 2 ball (A & B ) moving. When they collide. I want to be able to destroy ball A, but having no effect on ball B trajectory.
Yes I am, but this is not the problem of this thread ;-) I already saw the other thread, but thank you anyway :)
My problem occurs event if I dont destroy the ball.


bartbes wrote:Anyway, what about running world:update(0)?
It helps, but I still need to set the mask to make it works as I want

Code: Select all

    
self.shape:setSensor( true )
self.shape:setMask(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16)
world:update(0)
self.shape:setMask()
It's Ok for me , but I think having to do this is still a bit odd ...