• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by ytisfu · Mar 05, 2019 at 06:18 PM · physicsprofilertriggers

Is there any way to see exactly which triggers are overlapping?

I'm suddenly getting enormous spikes in my trigger overlaps, (according to the profiler) and I can't imagine why. Everywhere else in my level, the overlaps stay below 1k, and usually only 300 or so. But in a specific section, it spikes up to 2.6k, then later 3.6k, causing a lot of lag (I'm assuming it's the cause, since they happen at the same time). And there's only like 5 alive people in the level at the time, and a bunch of corpses (40+ people in a test scene runs great, even when they're all fighting each other, and under 300 overlaps)(also, ~100 corpses in the test scene ran really nice too, even less overlaps, so it's not them).

My main question here is: Is there any way to figure out what object(s) are causing these crazy overlaps? I feel like that would solve this. Any other suggestions are of course welcome.

Another related side question I had was whether a trigger needs to have some sort of OnTriggerEnter() / OnTriggerStay() etc attached to it to count towards the overlaps, or does it count regardless?

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image

Answer by bpaynom · Mar 06, 2019 at 09:17 AM

I don't actually know if there is a direct way to get it, but something i would try if not is this: In some script.

 public bool checkOverlaps = false;
 
 private void Update()
 {
     // You manually change it from the inspector when you want to check overlaps
     if( checkOverlaps )
     {
         checkOverlaps = false;
         CheckOverlaps();
     }
 }
 
 private void CheckOverlaps()
 {
     Collider[] colliders = FindObjectsOfType<Collider>();
 
     foreach( var col in colliders )
     {
         col.isTrigger = false;
         col.gameObject.AddComponent<CheckContacts>();
     }
 }



Then, use this script:

 public class CheckContacts : MonoBehaviour {
 
     private void OnCollisionStay( Collision collision )
     {
         foreach( var c in collision.contacts )
         {
             Debug.Log( name + " collides with " + c.otherCollider + " at " + c.point + " point " );
             c.thisCollider.isTrigger = true;
             Destroy( this );
         }
     }
 }

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

170 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

OnTriggerEnter triggers twice when changing the parent of a gameObject inside of a collider. 1 Answer

Active rigidbodies and number of Contacts 1 Answer

Physics.simulate and other functions getting called more than one times in a frame 0 Answers

Ignore collisions with self but still trigger with self 2 Answers

Physics.simulate taking a long time with an object 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges