Collision detection with no response

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
thib
Prole
Posts: 4
Joined: Tue Mar 15, 2011 12:12 pm

Collision detection with no response

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Collision detection with no response

Post by bartbes »

You're looking for sensors.
thib
Prole
Posts: 4
Joined: Tue Mar 15, 2011 12:12 pm

Re: Collision detection with no response

Post by thib »

I think this is exactly what I was looking for. Thank you very much!
thib
Prole
Posts: 4
Joined: Tue Mar 15, 2011 12:12 pm

Re: Collision detection with no response

Post 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 ?
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Collision detection with no response

Post 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.
Kurosuke needs beta testers
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Collision detection with no response

Post by bartbes »

@tentus: He's not trying to destroy it..

Anyway, what about running world:update(0)?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Collision detection with no response

Post 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.
When I write def I mean function.
thib
Prole
Posts: 4
Joined: Tue Mar 15, 2011 12:12 pm

Re: Collision detection with no response

Post 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 ...
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests