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 dubbreak · Feb 13, 2013 at 03:07 AM · physicsrigidbodycollideroptimization

Is a collider that enables/disables considered stationary?

I was watching a video on optimization from Unite 2012. One of the lecturers stated that if a collider ever moves it should have a rigid body attached (since every time a collider without a rigidbody moves a bunch of collision geometry needs to be recalculated).

My question is: If the collider is stationary (i.e. never moves) but you enable/disable it. Does it have the same impact as moving a collider? Should I add a rigidbody and set kinematic to true?

In the scene in question it's a box collider that prevents items from dropping away. At some point it is disabled, the items drop away (get destroyed when off screen) and then it's re-enabled.

Comment
Add comment · Show 4
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 dubbreak · Feb 13, 2013 at 10:36 PM 0
Share

Unfortunately the physics chapter of the Unity manual doesn't make this any clearer:

Static Colliders A Static Collider is a GameObject that has a Collider but not a Rigidbody. Static Colliders are used for level geometry which always stays at the same place and never moves around. You can add a $$anonymous$$esh Collider to your already existing graphical meshes (even better use the Import Settings Generate Colliders check box), or you can use one of the other Collider types.

You should never move a Static Collider on a frame by frame basis. $$anonymous$$oving Static Colliders will cause an internal recomputation in PhysX that is quite expensive and which will result in a big drop in performance. On top of that the behaviour of waking up other Rigidbodies based on a Static Collider is undefined, and moving Static Colliders will not apply friction to Rigidbodies that touch it. Ins$$anonymous$$d, Colliders that move should always be $$anonymous$$inematic Rigidbodies.

What I'm doing is basically level geometry (it stays in the same position for its life) it just gets disabled periodically.

avatar image dubbreak · Mar 11, 2013 at 07:56 PM 0
Share

Bump. Still interested in the answer to this.

Should a collider that is statically positioned yet gets enabled/disabled have a rigidbody applied? When I enable/disable is it doing a recomputation (same as moving an object)?

avatar image dubbreak · Jun 14, 2013 at 06:55 PM 0
Share

Still interested in a definitive answer to this question.

avatar image dubbreak · Aug 15, 2013 at 09:07 PM 0
Share

$$anonymous$$y question has no achieved a "Famous Question" badge, but still no answer.

Anyone have any input?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by RyanZimmerman87 · Feb 13, 2013 at 10:45 PM

I really do not like the unity manual guides. I am not very good with studying, and I usually find that their answers/examples only slightly point me in the right direction. There is always the possibility that the answers are outdated for older verions of Unity as well. I am not sure how often they update?

But anyways I believe the problems you are describing only occur when an object is moved with physics. So just enabling and disabling the object, I believe it should be fine as a static object.

This is however an interesting thing I need to consider for my own projects. Is it really that bad to move an object with a collider without a Rigidbody? I did not realize this could cause performance issues thanks for posting this question.

Anyone know more details about this? Seems counter-intuitive that a more simple object would be more performance heavy. Maybe this only applies to AddForce for the PhysX? If it applies to transform.position to even without a rigidbody... then well, I am confused.

And can't you check the tickbox to determine whether an object is static? It seems they are saying it's an automatic function?

It is really rare when the Unity manual actually helps me. I find that solving problems based on their examples/answers is usually like banging my head into a wall repeatedly until I happen to hallucinate the right solution.

They should really have more in depth examples and guides for those of us who aren't "pros", or "geniuses".

It almost seems like they want you to have trouble learning this stuff, or they are VERY bad teachers.

Comment
Add comment · Show 4 · 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 dubbreak · Feb 13, 2013 at 11:03 PM 0
Share

I first heard about it in this video on performance optimization from Unite 2012. I can't be bothered to rewatch it right now, but I don't remember them specifying moving using physics, just moving it at all. The manual seems to agree (if it doesn't stay stationary.. meaning the same transform to me) then it should have a rigidbody (and of course is kinematic to true).

I'm mainly wondering in my case if I'm getting overhead by enabling/disabling or I'm not and it's best kept that way do to the overhead of a rigidbody (which isn't all that bad in this case as it's just one simple collider).

While not a huge deal in my current usage these are things I like to know. Of course I'm the type of person that gets overly concerned with what my OR$$anonymous$$ is doing so I can avoid extra round trips to the DB.

avatar image RyanZimmerman87 · Feb 13, 2013 at 11:11 PM 0
Share

Yeah, I wish I had the answer too. Hopefully someone will come along to clarify this for us.

I also think I read somewhere that you should always use AddForce with Rigidbodies never transform. So maybe it is ok to use transform without Rigidbodies? Or do all movements require a rigidbody?

I have found that moving Rigidbodies with transform works perfectly as far as I can tell...

So once again there guides have been very unhelpful to me. Please someone clarify this?

avatar image RyanZimmerman87 · Feb 16, 2013 at 11:54 PM 0
Share

Anyone? Still curious about this, I cannot seem to ever find the time to fully read through all the documentation as it generally just leaves me with more questions like this.

avatar image dubbreak · Feb 19, 2013 at 02:40 AM 0
Share

I'm still interested too. The documentation is ambiguous. If all else fails I can go to the optimization talk at Unite 2013 Vancouver (if they have a talk on that) and ask the question there. I'd kinda like to know before then though.

avatar image
1

Answer by Jonny-Roy · Aug 15, 2013 at 09:45 PM

I would so no, reason being is as follows:

Each collider that is created static gets copied into the physx engine, this then combines and optimises into a single optimised mass collider routine, so basically they would not be one collider but get grouped so that near calculations can be made to work out which colliders should be tested.

If you enable or disable any of these, unity only tells physx to ignore collisions (in the same way as how layers work and ignore colliders work) but the grouping remains.

However if you create a new one or move a static one, the whole lot gets recalculated...which is really slow.

Ultimately any questions on whats faster, what will affect performance...just write a quite test and check the performance.

Comment
Add comment · Show 3 · 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 dubbreak · Aug 15, 2013 at 10:45 PM 0
Share

If I had pro I would definitely profile it. Easy enough.

Someone from Unity Tech should be able to give a definitive answer though. At this point it's just conjecture. Yeah a new collider or moving a static will definitely be poor performance, but this may be an edge case since enabling/disabling isn't the same thing as moving or creating a new one.

avatar image Jonny-Roy · Aug 16, 2013 at 07:30 AM 0
Share

You can use Time.realtimeSinceStartup to measure time functions take for example stick this in your update and check the debug log:

     var time=Time.realtimeSinceStartup;
     for(int i=0;i<10000;i++)
     {
         this.TestCollider.enabled=!this.TestCollider.enabled;
     }
     Debug.Log("Time taken="+(Time.realtimeSinceStartup-time));

$$anonymous$$y results show:

0.06993103 seconds (69ms)

On my mac book air. So if you're toggling 10000, then start to worry!

You won't get an answer from Unity Tech, as it's not really a Unity question, it's a Physx question, and so would really be something to be asked at Physx.

avatar image dubbreak · Aug 16, 2013 at 02:41 PM 0
Share

I'll try it on mobile see if there's any notable difference between static and dynamic.

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

11 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

Related Questions

Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer

Raycaste vs trigger Colliders & Rigidbody performance 1 Answer

Rigidbody not sleeping 1 Answer

Vertical push doesn't let the object fall down instantly 1 Answer

Stopping my player from moving when hitting a wall. 5 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