Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by douglasg14b · Apr 03, 2015 at 07:47 PM · physicsperformancecolliders

What is Physics2D.Simulate, and why is it chewing up more than 100ms of frame time? And why does this not happen when using 3D physics?

Important Edit At Bottom Of Post

If I try this with 3D colliders and physics it get ~5-10x the performance

I made a fairly simple test scenario where I had a bunch of ships all shooting at a central target. Each turret has it's own circle collider that's used to check it's range from a specific target (and to identify if a target has entered it's range). They also have a 2D line cast to make sure their target is within line of sight, and is also within a certain range.

The projectile is a small sprite with a small circle collider attached and a rigidbody.

I have 80 turrets shooting one projectile every 10 seconds (staggered) and 4 turrets shooting 10 projectiles per second. I noticed the performance tank the more turrets I added, even if none of them where actually firing.

alt text

alt text

What is this Physics2D.Simulate, and what can I do about it's horrible performance in this situation?

Additionally, Unity is only using ~11% of the performance available on the threads it's utilizing, yet the frame-rate is so low. Any comments on that?

Edit: I tried instantiating 120 projectiles per second from a single unit to see if it was the rigidbody movement, after over a thousand projectiles I was still at 90FPS. It does not seem to be that. It also does not seem to be the OnTriggerEnter or OnTriggerExit behavior either, since that is under Physics2D.ContactReporting.

Edit2: I created a part of the scene with 80 empty gameobjects and added a circle collider to each with IsTrigger selected. When the projectiles fly through the colliders the game goes from 700FPS to ~1-2FPS in waves. It will be fine for a few seocnds, then the Physics2d.Simulate spikes to a few hundred ms for a second or two, then it goes down for the next 3-4 second, then back up, then back down. I can't make much sense of it.

Screenshot of slowdown: alt text

Screenshot of colliders: alt text

GIF of firing: alt text

Comment
Add comment · Show 3
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
avatar image _Kyle_1 · Apr 03, 2015 at 09:32 PM 0
Share

I have no idea what the issue is, but good luck with finding it out. I hoped I helped a little.

avatar image douglasg14b · Apr 03, 2015 at 10:59 PM 0
Share

Oh man, you really should not have deleted your answer. I had a lot of explanations under it. Thank you for your time though.

Edit: Copy/Paste of previous explanations that may not be included in the OP.

The reason I'm asking this is because I don't really have that many objects in the scene yet. 20 units with 4 turrets each for a RTS is VERY conservative. The lag actually starts up with only ~6 units and 24 total turrets. I've been program$$anonymous$$g with performance in $$anonymous$$d, but I cannot figure out how to resolve the physics lag. With a single unit I'm hovering around 3,000FPS with vsync off, and with 6 I'm down to 50FPS.

It seems a bit silly to have a RTS-like game with a 10 unit world population limit. I know there seems to be a relation between units, their colliders, and the projectiles. However I have no idea how to improve the performance, or what the root of the problem is.

I do. 20 units, 4 turrets each, 80 turrets. Essentially 80 spots where a projectile is instantiated and force is applied. (No object pooling yet, though that seems to be unrelated to this issue). Each projectile has a rigidbody2D and a circle collider 2D attached to it. They are not kinematic. Each turret has a circle collider that is essentially it's range, it gets notified when something has entered and when something has left the collider (Physics2D.ContactReporting).

Where do you think the performance hog may lie? It's not the OnTriggerEnter or OnTriggerExit methods, since both of those fall under ContactReporting. I can instantiate 120 projectiles per second till I have thousands of projectiles flying on the screen and hang around 90FPS, so it doesn't seem to be the movement of rigidbodies.

I'm at a loss

avatar image jjulio93 · Jan 10, 2017 at 03:27 PM 0
Share

Hi, have you found any solutions to this problem? I'm having a very similar problem and have not found any solutions.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Shibli · Nov 09, 2016 at 12:44 PM

Hey, I found a potential solution. If you go into project settings-> physics you can change the collision matrix and turn all collisions off except for collisions between bullets and units. Unnecessary collision checking could be hogging cpu resources.

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Active rigidbodies and number of Contacts 1 Answer

Box collider vs Quad(mesh) collider 1 Answer

Performance issues with trigger colliders and lots of projectiles. 2 Answers

Temporary disable collision, what's best performance-wise 1 Answer

THIN objects can fall through the ground? (AMAZING SOLUTION) 2 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