• 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 EvanDela · Aug 22, 2011 at 12:03 AM · lag

Physics grinds my game to a halt...

Hi All, I am sorry, I just don't know what I am doing wrong here. I have learn't a lot while trying to find an answer, but nothing I have learn't helps.

I have an empty game object, and to it, I have attached a script. In the start event of the script, I run a nested loop and create a wall of cubes 10x10, each cube has a rigid body attached and has a custom physics material with 0 bounciness. When the game runs, i would expect the wall to come tumbling down - and this is what it does BUT as the physics kick in... it becomes REALLY laggy.

Can someone please point me in the right direction here ?

Comment
Add comment · Show 1
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 TheDarkVoid · Aug 22, 2011 at 12:39 AM 0
Share

the more physics objects in the game cause more lag, especially in the editor

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Peter G · Aug 22, 2011 at 12:55 AM

There are a lot of things you can do to fix it:

  1. Use fewer rigidbodies. It's that simple, but a lot of the times you don't have choice.

  2. Avoid using mesh colliders and other complex colliders such as wheel colliders. Physx has to calculate collisions for each collider so the more you have the longer it will take. Mesh colliders and wheel colluders are the two most expensive to calculate so you should try to use cheaper colliders when you can.

    Note: Physx probably does bounding volume checks to avoid calculating some collisions, but that won't help you much in your case with a wall.

  3. The physics time step is another very important piece that you need to work out. Found in the time manager, the physics time step determines how often the physics loop runs. Running it more frequently gives you more accuracy at the expense of performance. The higher you can set this number (hence making it run less frequently), the better. You can turn on interpolation in individual rigid bodies to help smooth out the jumps between physics loops for larger time steps.

  4. In the Physics settings, the solver iteration count can also hurt performance. This factors into how many loops the physx does in calculating your collisions. Again, its more accurate the higher the number, but it will also slow down performance.

  5. Run in a build. The editor gets poor performance because it has all sorts of things going on in the background while playing. Test your app in a build to get a better idea of how laggy it really is.

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.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Android Build Lagging 0 Answers

How to compensate 100 millisecond delay from Laser Gun to Mouse click 0 Answers

I need help with lag reduction 1 Answer

Rigidbody load problem 1 Answer

Network.update spiking... 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