I was attempting to use the bepu Box as a trigger for my enemies by setting its personal rule to NoSolver, constantly centering one on each enemy, and looping through its contacts to find if the player was touching the trigger.I noticed that my game's performance went down exponentially as I made the trigger's size larger; I'm guessing this is because of how many contacts are being created between the trigger and the level's StaticMesh, among other entities lying around.
Is there any way to make this more efficient, short of constricting the size of the area? Or should I not even be doing this sort of "aggro radius" trigger with bepu in the first place?
Large Trigger Areas
Re: Large Trigger Areas
If the goal of the volume is only to detect players, I would recommend using either group rules or specific rules instead of a personal rule. For example, if a specific rule is created between the player object and the detector, it won't generate contacts with anything else and performance will be a lot better.
If the purpose of the volume is just to see if players are nearby-ish and you don't care about detail at the level of contacts, using a volume query would be a lot faster. Something like Space.BroadPhase.QueryAccelerator.GetEntries(BoundingSphere, entries).
Using a pure query like that would also enable other optimizations. If the volume is just meant to be an awareness test, then it probably doesn't need to run every single frame. Once every 10 frames would probably be enough. If you've got a lot of enemies, their queries could be distributed across the frames uniformly.
If the purpose of the volume is just to see if players are nearby-ish and you don't care about detail at the level of contacts, using a volume query would be a lot faster. Something like Space.BroadPhase.QueryAccelerator.GetEntries(BoundingSphere, entries).
Using a pure query like that would also enable other optimizations. If the volume is just meant to be an awareness test, then it probably doesn't need to run every single frame. Once every 10 frames would probably be enough. If you've got a lot of enemies, their queries could be distributed across the frames uniformly.
Re: Large Trigger Areas
Ah! I see. Thank you Norbo, your beautiful brain is as enlightening as always ![Smile :)](./images/smilies/icon_smile.gif)
![Smile :)](./images/smilies/icon_smile.gif)