• 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

· Add your 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

OnCollisionEnter,OnTriggerEnter making profiler spike 1 Answer

Profiler Physics.Simulate spikes 2 Answers

Spikes with Physics.Simulate() in empty scene? 0 Answers

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

Did triggers inside loaded gameobjects break in a recent update? 0 Answers


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