Help me unpack this wiki page

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
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Help me unpack this wiki page

Post by togFox »

I get not everyone uses or even likes vanilla physics engine but maybe you can decipher this page:

https://love2d.org/wiki/Fixture:setFilterData

I have multiple physics objects on the blue team.
I have multiple physics objects on the red team.

Blue team can not collide with anyone.
Red team can not collide with anyone.

However, both teams can shoot projectiles at each other (physics) and those projectiles can collide with blue or red, but not other projectiles.

What filter do I need?
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
Ross
Citizen
Posts: 98
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: Help me unpack this wiki page

Post by Ross »

I don't use the "group" feature, it's never seemed necessary.

"categories" and "mask" are bitmasks. "categories" represents the categories that the fixture is a member of. "mask" represents all the categories that the fixture will collide with.

You probably want a category each for blue team and red team, and a category for projectiles.

Members of both teams should mask out the "blue" and "red" categories (set those bits to 0 in the "mask") so they don't collide with members of either team.
togFox wrote: Tue Jul 05, 2022 2:34 am However, both teams can shoot projectiles at each other (physics) and those projectiles can collide with blue or red, but not other projectiles.
This isn't 100% clear to me. Is there friendly fire? Should projectiles only hit the opposing team, or should they collide with a member of either team?

If projectiles shouldn't collide with each other, then mask out the "projectiles" category for them.

If projectiles shouldn't hit the friendly team members, then mask out that team's category.
If projectiles should hit both teams' members, then you don't need to mask out either team's category.

Personally, I made a small module to map string names to each category that I use, and a couple functions to generate the bitmasks from a list of names. So I never have to think about the actual numbers anymore. Let me know if you want me to share it.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Help me unpack this wiki page

Post by togFox »

Any projectile can hit any player/team so - yes - friendly fire is a thing.

I guess, in hindsight, I should have said players can only hit projectiles and projectiles can only hit players.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
Ross
Citizen
Posts: 98
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: Help me unpack this wiki page

Post by Ross »

OK, in that case you only need two categories: one for players and one for projectiles.

Players mask out players, and projectiles mask out projectiles.
Post Reply

Who is online

Users browsing this forum: No registered users and 89 guests