Hello,
I was hoping to use the box2d's contact filtering to determine whether or not certain objects should be able to collide with each other. For example, I want a player to pass right through his own bullets. I can't find it in the LÖVE physics documentation. Is it not yet implemented?
Thanks!
Contact filtering
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Contact filtering
I guess you need Shape:setMask()
Re: Contact filtering
Aha! I figured it would be under Body, or maybe World. Good to know.
Re: Contact filtering
Yep, for each shape (either circle or polygon) you can:
1. put it in one or more categories using :setCategory()
2. designate which categories the shape should not collide with, using :setMask()
These functions take any number of arguments which are numbers from 1 to 16 (there can be no more than 16 categories), for instance:
The similar functions setCategoryBits() and setMaskBits(), which ask for a number that corresponds to a bit set for each category, are going to be removed in the next release of LÖVE, because they are far more annoying to use.
1. put it in one or more categories using :setCategory()
2. designate which categories the shape should not collide with, using :setMask()
These functions take any number of arguments which are numbers from 1 to 16 (there can be no more than 16 categories), for instance:
Code: Select all
myshape:setCategory(1,4,5)
myshape:setMask(2,3)
"When in doubt, use brute force." Ken Thompson
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 10 guests