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
2
Question by beck · Aug 01, 2012 at 08:38 PM · rotationperformanceoptimizationprofilerprofiling

Rotation Performance

Can anyone see why this might be happening?

alt text

I am seeing some really terrifying profiler output on a very simple call: transform.rotation_set. Setting the rotation of an actor seems to be taking very long. There are a large number of actors in the scene, but each of them are performing operations which seem much more complex than just setting rotation. Rotation is taking up 1/4 of the AI calculation, even when run next to a lot of physics and pathfinding code.

Each actor has between 20-30 children, and most of them are just empty nodes part of the bone hierarchy. Each actor has a skinned mesh renderer, a kinematic rigidbody, an animation, and a capsule collider. Could any of these components the culprit to this performance impact?

Any insights on how to improve this would be great. I'm trying to optimize these actors as much as possible.

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 adbourdages · Oct 16, 2012 at 03:19 PM 0
Share

I can't upvote, but I'm seeing the same problem.

avatar image Matou · May 14, 2014 at 12:47 PM 0
Share

It's a bit late, but same for me! $$anonymous$$y object also has a complex animated hierarchy, and a CharacterController component... And I'm setting the rotation in FixedUpdate().

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by adbourdages · Oct 17, 2012 at 03:15 AM

I have just discovered the function RigidBody.MoveRotation() didn't have the same impact as setting the rotation of the rigidbody's tansform. You pass a target rotation and internally uses forces to get the rigidbody rotation to the proper value.

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 Radiangames2 · Jul 07, 2016 at 08:34 PM 1
Share

Just wanted to thank you for posting about this magical function. We have complex objects (20+ children each) that used transform.rotation = ..., and switching to RigidBody.$$anonymous$$oveRotation() had a significant impact on our framerate.

As for our theory on why setting transform.rotation is so slow: It might be calling GetComponent on every subobject as it updates their transforms. That's the only reasonable explanation we can imagine for why it's so horrendously slow and inefficient compared to RigidBody.$$anonymous$$oveRotation().

avatar image Harinezumi Radiangames2 · Jun 25, 2018 at 12:51 PM 0
Share

I know this is very old, but the aside from the possible GetComponent<Transform>() (which I think was optimised in Unity 5) the actual reason why modifying the rotation (or position) of a game object with rigidbody is slow, is that this circumvents the physics system and all the physics of the object needs to be recalculated. I've found a comparison of the performance of setting position different ways, and the result was that if you have a rigidbody, ALWAYS use Rigidbody.$$anonymous$$ovePosition() and $$anonymous$$oveRotation().

avatar image
0

Answer by JanWosnitza · Oct 16, 2012 at 04:23 PM

You could try to set the rotation in FixedUpdate. Since all physics is singlethreaded (an other thread than Update) it may be that setting the rotation will wait until next FixedUpdate.

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

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

UI Text Optimization? Updating Geometry seems to be slow 0 Answers

Is there a Per-Mesh-Profiler somewhere? 2 Answers

Make Profiler ignore a particular function? 0 Answers

Scene Lag when first running a certain script, but then returns to normal performance afterwards? 1 Answer

Huge "Device.Present" performance hit in profiler 0 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