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.

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.

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.