- Home /
Can you move a rigidbody without causing it to activate?
I'm trying to move a bunch of kinematic rigidbodies around (they also each have a collider attached). However, each time I move one, I see a drop in performance in the profiler. When not moved, the profiler says there are no active rigidbodies. However, as soon as I move one (or a group of them) it/they become active and there's a performance drop.
All I want to do is shift their position over 1 frame. They don't need to collide or interact with anything in the process. How do I do this without them activating and causing a drop in performance?
Answer by flaviusxvii · Jun 20, 2011 at 09:21 PM
Moving such things causes PhysX (the underlying physics engine) to rebuild it's broad-phase collision detection trees. It doesn't matter if they aren't colliding.
Hard to tell without knowing more details of what you're trying to accomplish with them.
Well, it's as simple as the original description. I have a bunch of kinematic rigidbody colliders, and I just need to reposition them without taking a physics hit. They won't be colliding with anything during the move.
Does using rigidbody.moveposition work faster than accessing transform.position directly?
Hmm...it seems as though having the rigidbody on an empty gameobject, and then having the collider parented to that rigidbody.....and then moving the collider object while the rigidbody parent stays stationary doesn't activate the physics engine. I'll do some more tests, but that might be the solution I'm looking for!
"I have a bunch of kinematic rigidbody colliders"
Yeah, I read what you wrote, and this is a solution you've come up with, but what are you using them for? You might be going about it all wrong for all I know. I can't tell you what to do without knowing what your use case is. Teleporting rigidbodies is quite unnatural.
Answer by _Petroz · Jun 21, 2011 at 02:09 AM
Try putting the RigidBody to sleep before you move it.
http://unity3d.com/support/documentation/ScriptReference/Rigidbody.Sleep.html
Rigidbodies can also be forced to sleep using rigidbody.Sleep. This is useful to start rigidbodies in a rest state when loading a new level.
Taken from http://unity3d.com/support/documentation/Components/RigidbodySleeping.html
Unfortunately this won't prevent a potentially drastic rebuild of the physics broadphase. I actually have fairly intimate knowledge of PhysX so I am pretty sure this is the case.
Answer by testure · Jun 21, 2011 at 05:17 AM
You could destroy your rigid body when you don't need it, and then add it back when you need it again.
Destroy(rigidbody);
and when you need it back:
gameObject.AddComponent(Rigidbody);
Your answer
![](https://koobas.hobune.stream/wayback/20220612112958im_/https://answers.unity.com/themes/thub/images/avi.jpg)