Ignore collisions by type of Entity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
oclock
Posts: 2
Joined: Thu Jul 25, 2019 6:31 pm

Ignore collisions by type of Entity

Post by oclock » Fri Jul 26, 2019 5:56 pm

What's the best way to turn off the collisions between objects of certain types?

This would be for cases such as "No players should ever collide" or "No projectiles should ever collide" as well as "No Players of Team A should collide with projectiles of team A".

I started by building out groups to handle this, but it gets tricky in a deathmatch scenario. Then I need groups for Team A, Team B, C, D, etc. And groups for their projectiles, etc. In this case Player Team A has NoBroadphase with Proj Team A, Player Team B, C, D, etc.

Other option is as I add new Characters/Projectiles to the space, I can run through the already existing characters/projectiles and create rules via CollisionRules.AddRule accordingly.

Is there an easier way I'm missing?

Norbo
Site Admin
Posts: 4708
Joined: Tue Jul 04, 2006 4:45 am

Re: Ignore collisions by type of Entity

Post by Norbo » Fri Jul 26, 2019 9:31 pm

Within the default collision rules setup, a group for each type with appropriate rules would likely be easiest.

Note that you can supply a custom callback for CollisionRules.CollisionRuleCalculator and then do whatever you want. Cast the input to the known type, grab some custom data stored in a Tag property or something equivalent, and then perform custom logic on that custom data. Packed integer representations are common. A conceptual example of packed integer filters can be found in the v2 ragdoll demo: https://github.com/bepu/bepuphysics2/bl ... emo.cs#L88

(v2 does away with built in collision filtering 'systems' in favor of just providing a callback.)

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests