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
1
Question by manny003 · Mar 06, 2015 at 02:27 AM · colliderunity5performancerigidbody2dphysics2d

Unity 5: RigidBody or No RigidBody?

I have slow moving gameObjects that are moved exclusively with code. They have colldiers and are never affected by physics in anyway.

Up until now, it was clear that I needed to have a rigidbody2d (mine is a 2d game) attached, flagged IsKiematic, for optimal performance because of the way the physics engined worked internally.

I am aware that Unity 5 has optimized the engine so that there is no longer the performance penalty that was seen prior when moving a collider without a rigidbody.

Still, since I'm obsessed with squeezing out every last possible ounce of performance, especially for mobile, can I get the last word about whether or not there is still a performance gain to be had, no matter how small, with having a rigidbody as opposed to not? Or the other way around?

I've search the Internets but have gotten conflicting thoughts, most of them very vague and probably just guesses.

Thanks, Manny

Comment
Add comment · Show 2
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 tanoshimi · Mar 06, 2015 at 06:46 AM 1
Share

Unity 5 includes a profiler, even with the personal edition; this sounds like an ideal opportunity to learn to use it by conducting performance tests yourself with and without rigid body components. Please do share your results.

avatar image christophfranke123 · Mar 06, 2015 at 11:28 AM 0
Share

I have observed that when moving a collider by assigning its transform.position, then the collider gets removed and recreated, causing a fair amount of overhead (still in unity 5 beta17). Is that the performance problem you mean?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by MelvMay · Mar 13, 2015 at 04:37 PM

I am aware that Unity 5 has optimized the engine so that there is no longer the performance penalty that was seen prior when moving a collider without a rigidbody.

This applies to 3D physics (PhysX), not 2D physics (Box2D). It's quite simple; static colliders are called static because they are designed to not move so never ever do so. All static colliders are added (behind the scenes) to a single static body. This means we don't have a static body for each static collider which, for obvious reasons, is far better however it also means that this single static 'ground body' lives at the world origin thus when you 'resposition' a static collider, it has to be recreated at the new position you specify. Technically the colliders geometry is transformed to the position but the single static body stays at the world origin. This isn't normally a problem because nobody should ever move (during gametime) a static collider. So never move a static collider. You can trust me on this because I wrote the physics code that does it. :)
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 Ultroman · Jul 14, 2016 at 11:04 AM 0
Share

Is this still the case?

I have some sprite-men that move around in a sidescroller-like game. Each of them has a box collider (trigger, to catch clicks) and a sphere collider (non-trigger, for the head), but no rigidbody. I move the men using transform.position = ??? in Update(). I have about 20 on-screen at the same time, and I don't seem to experience any lags or inconsistencies. I successfully have rocks (with rigidbodies) falling onto their heads, and bouncing off. None of the prefabs are set to be Static, if that makes any difference. How does one set a collider to be static or not?

Is it still advisable, to only move my sprite-men in FixedUpdate? And is it still advisable to attach a rigidboy to them, and set it to Is$$anonymous$$inematic? It seems like a lot of overhead, just to be able to move a bunch of colliders.

avatar image Ultroman Ultroman · Jul 15, 2016 at 11:51 AM 0
Share

I read up on it, and apparently the answer is "Yes."

At least for 2D, if it moves, it should have a rigidbody and be moved in FixedUpdate using either:

  • physics-methods e.g. ApplyForce()

  • rigidbody.$$anonymous$$ovePosition(), which interpolates kinematic objects to the given position, but teleports non-kinematic rigidbodies instantly.

  • rigidbody.position = someVector, which teleports both kinematic and non-kinematic rigidbodies instantly.

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

24 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

Related Questions

Rotating child object in compound collider 0 Answers

Strange Circle collider 2D physics behaviour 1 Answer

2D Physics: Circle's velocity vector becomes parallel to collider's edge after collision with small angle 0 Answers

Unity5 rigidbody2d not working properly... :( 1 Answer

Why Rigidbody2D gameobject automatically translating to Vector2.zero itself 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