- Home /
Profiling mysterious "Phase Core: Trigger Interaction Work"
I've been running profiling tests to improve the performance of my game, and I've discovered something that seems to be hogging an absurd amount of resources. The function in question is called "PhysX.ScNPhaseCore.triggerInteractionWork".
It's using up 40ms, which seems way too high compared to rest of the items listed there. I have a rough idea where this call is coming from, but I don't know exactly what objects are causing it occur. What's more is that I don't know why it's being made exactly, and why there are 173 calls of it. There's nothing in the documentation that lists what it does, but I'm assuming it has to do with the OnTriggerEnter function; which is strange, because there's already a profiler item for those types of calls under Physics.ProcessReports. It's true that I have many triggers in my scene, but the problem only seems to flare up when a few entities enter just a couple overlapping triggers. I even tried restricting the Physics layer to see if my triggers would ignore some moving parts on the enemies, but it didn't seem to help. Maybe the problem is coming from somewhere else...? But I have no clue where to look since, even in a Deep Profile, there's no information on what objects called it. In the "show related objects" everything is just N/A.
Does anyone know what this function is supposed to do? How can I track down what's causing it be called so many times? Do I have to just use trial and error to eliminate the possibilities one by one? Thanks in advance!
Answer by GreenPandaStudios · Feb 24, 2021 at 03:27 PM
@SomeGuy22 I'm having the exact same issue. Everything is perfectly optimized to run well over 60 fps, and suddenly there are these massive spike in Physics processing due to PhysX.ScNPhaseCore.triggerInteractionWork. Were you able to find a fix for this annoying issue? Or learn anything more about what's causing it?
There is no specific fix, I think this is just the work that Unity is doing to process Triggers. If you have a lot of moving rigidbodies inside triggers (even kinematic) then it causes the OnTriggerEnter etc. callbacks. If your trigger itself is a rigidbody (even kinematic) then any collider that moves within it will also get the callbacks. Unfortunately there seems to be no way to track down which objects are causing the spikes in that call, at least none that I've found yet. That would be a huge help in finding what to optimize.
Instead for a different game I worked on I was able to just split my triggers/collisions into more layers and manage the collision matrix so that colliders that didn't need the trigger calls would be ignored when they're inside the trigger. Specifically a case was that I had ragdoll components on a character and I could disable collision between those components and the trigger box they were moving inside. Other than that there is just nothing more you can do for now, sorry. Reducing the amount of calls to it (the amount of trigger interactions) is a concrete number you can try to decrease for more performance.