Help with filter data

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
Dialglex
Prole
Posts: 9
Joined: Tue Feb 07, 2017 6:14 am

Help with filter data

Post by Dialglex »

I have tried to implement filter data into my game but I am having troubles.
I have the map, 4 cars, and bullets from each car. I want everything to collide with the map. I want the cars to collide with everything, except their own bullets. I want the bullets to collide with everything except their own car and all other bullets.
What filter data should I set each of these fixtures to be to do what I want them to do?
TheMajesticMagikarp
Prole
Posts: 8
Joined: Tue Apr 11, 2017 12:11 am

Re: Help with filter data

Post by TheMajesticMagikarp »

I think it would be easier for someone to help if you would provide the code you have written. I am also confused about why you would need for the bullet to not collide with the same car.
User avatar
erasio
Party member
Posts: 118
Joined: Wed Mar 15, 2017 8:52 am
Location: Germany

Re: Help with filter data

Post by erasio »

Actually the code should make very little difference since the question is specifically about physics filter data (groups, categories & masks).

The code to set those is trivial. So is integrating it into your system (be it ecs, classic oop, functional or a mix).


My suggestion to you OP would be. To mostly rely on negative groups and mask projectiles from one another.

Short overview about how this works. Firstly I'd suggest not using the setFilterData function. It's not well documented and this all at once type of thing. I prefer using the individual functions.
setGroupIndex, setCategory and setMask.

The group index is basically an override of the other settings. Positive means they'll always collide. Negative means they'll never collide.

So by setting each car and it's projectile to a specific group id (let's say -1 to -4). So each car will never collide with anything that belongs to it.

On top of that to prevent projectiles from colliding you can set the category of all projectiles to a shared value. And mask the same category. Since all projectiles share the same category and all have been set to ignore that category. Projectiles will never collide.

Cheers
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 36 guests