Page 1 of 1

How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 9:31 am
by Ovidios
I just want an object to act as though it wasn't there, not colliding with anything? How would I do that?

Thanks in advance!

Re: How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 10:03 am
by Vimm
Not quite sure what you mean. If you don't want one object to collide with another object just don't check for collisions.

If you mean you only want it to not collide when say, a button is being held down, you could set a Boolean variable like canCollide=true
Then you could set that to false when you hold the button and have collision be checked only if canCollide is true.

Without knowing exactly what you mean and/or seeing the love file, it's hard to help, at least hard for me to help but I'm pretty new lol

Re: How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 10:16 am
by Ovidios
Vimm wrote:Not quite sure what you mean. If you don't want one object to collide with another object just don't check for collisions.

If you mean you only want it to not collide when say, a button is being held down, you could set a Boolean variable like canCollide=true
Then you could set that to false when you hold the button and have collision be checked only if canCollide is true.

Without knowing exactly what you mean and/or seeing the love file, it's hard to help, at least hard for me to help but I'm pretty new lol
I'm using the physics-module and don't know how I would go about disabling collisions (both check and callback) for one body/shape/fixture. Sorry for not making that clear enough.

Re: How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 10:46 am
by Vimm
Ovidios wrote:
Vimm wrote:Not quite sure what you mean. If you don't want one object to collide with another object just don't check for collisions.

If you mean you only want it to not collide when say, a button is being held down, you could set a Boolean variable like canCollide=true
Then you could set that to false when you hold the button and have collision be checked only if canCollide is true.

Without knowing exactly what you mean and/or seeing the love file, it's hard to help, at least hard for me to help but I'm pretty new lol
I'm using the physics-module and don't know how I would go about disabling collisions (both check and callback) for one body/shape/fixture. Sorry for not making that clear enough.
Ah I don't think I can help then, I tend to avoid the physics module for reasons like that. I generally check collisions just by using a collision function

Re: How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 10:51 am
by Tanner
The easiest way is to use 'Fixture:setFilterData' to set the collision filtering mask to 0. Assuming you haven't changed any of the category, mask or group data, that would look like this: 'fixture:setFilterData(1, 0, 0)' and then turning collisions back on would be like this: 'fixture:setFilterData(1, 65535, 0)'.

Love also provides 'Fixture:setMask' (https://love2d.org/wiki/Fixture:setMask) which is a nicer way of dealing with those masks if you aren't used to bitwise operations. In your case where you want to turning everything off, though, 'setFilterData' is probably more straightforward.

You can read more about this stuff in the Box2D manual. http://www.box2d.org/manual.html

Re: How do you temporarily disable collisions? - love.physics

Posted: Sun Apr 17, 2016 11:44 am
by Ovidios
Tanner wrote:The easiest way is to use 'Fixture:setFilterData' to set the collision filtering mask to 0. Assuming you haven't changed any of the category, mask or group data, that would look like this: 'fixture:setFilterData(1, 0, 0)' and then turning collisions back on would be like this: 'fixture:setFilterData(1, 65535, 0)'.

Love also provides 'Fixture:setMask' (https://love2d.org/wiki/Fixture:setMask) which is a nicer way of dealing with those masks if you aren't used to bitwise operations. In your case where you want to turning everything off, though, 'setFilterData' is probably more straightforward.

You can read more about this stuff in the Box2D manual. http://www.box2d.org/manual.html
Thanks! Got it to work using "Fixture:setMask" since I only had one moving object!