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
3
Question by misterPantoni · Feb 16, 2013 at 09:24 PM · physicsioscolliderperformanceprofiler

Moving Colliders giving me Physics.simulate spikes in Profiler

Hi there,

i'm currently prototyping a mobile game and i'm a bit stuck because of some performance issues. The thing is: I have a somehow "grid" of cubes (16x16), which are moving every now and then (usually each 5 seconds). They all need to have a collider/Trigger on, because i need to Raycast against each one of them.

Problem is: If i'm moving them by script (setting transform.position), i get ugly lags, caused by Physics.simulate (so says profiler). If i remove the collider everything is smooth, but i really need to Raycast against them... I don't need physics for anything else than the Raycasts, so no rigidbodys or whatever involved. Already tried to increase fixed Time, lowered physics solver iteraton count and all the other Physics settings - with no success.

Any Ideas how to solve this?

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

2 Replies

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

Answer by liszto · Feb 17, 2013 at 12:38 AM

If I remember of Physics rules :

  • If you move object with collider by script it can generate high lags cause an object with a collider must stay static.

  • If you want move the object by script you must give it a rigidbody an define it as kinematic. Then if you want move it during an update, you must move it in fixedUpdate and not in Update.

  • As advice, yo ucan watch the video named "Unite 2012 - Performance Optimization Tips and Tricks for Unity" at this link : http://unity3d.com/unite/archive/2012 and watch between 21.30 and 25.00 roughly. All your answers are here ;)

Comment
Add comment · Show 2 · 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
avatar image pumuckli · Feb 20, 2013 at 09:52 AM 0
Share

Thanks a lot for your answer, i watched the video and got a few more hints how to optimize my game, thanks! Actually adding a rigidbody is not really the solution to my problem because i would have a lot of rigidbodys - i tried it and performance is dropping really bad. I do not move the objects in Update (or fixed Update), just every 5 Seconds and as i already said i really don't need them for enything else than raycasting... I'll have to try something else i think.

avatar image liszto · Feb 20, 2013 at 02:14 PM 0
Share

Think to look Bunny solution I totally forget to talk to you about Physics collision matrix in Edit/Project settings

avatar image
3

Answer by Bunny83 · Feb 20, 2013 at 10:23 AM

If you need the colliders just as raycast hit object do this:

  • Make sure they are set to isTrigger

  • Create a new layer for the objects and put them all on this layer

  • Go to Edit -> project settings -> Physics and disable all interactions in the collision matrix. So just clear the row and column of your layer in the matrix.

  • When raycasting against them make sure you use the layermask and pass a layermask that only contains the layers you want to raycast against.

Comment
Add comment · Show 1 · 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
avatar image null_loop · Nov 14, 2014 at 10:26 PM 0
Share

This little tidbit has just saved me a good 30FPS on a few thousand objects with the game time at x100 - it's made it possible to massively expand the number of objects I can include. Thank you!

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

12 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

Related Questions

Mesh collider cost 1 Answer

Fastest primitive collider 1 Answer

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

Random Performance Spikes due to Physics.Processing in a static scene. 1 Answer

Box collider vs Quad(mesh) collider 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