Showing results for 
Search instead for 
Did you mean: 
Honored Contributor III

Unity Tip: Reducing Rigidbodies In RealSense Projects In Unity 5

Hi everyone,

Those who were using RealSense with Unity back in versions 4.5 and 4.6 may have come across a situation where an object containing a TrackingAction SDK script would sometimes have a red error message if that object did not also contain a Rigidbody physics component.  In my own case at least, I got into the habit of giving every RealSense-powered object a Rigidbody to make sure that the error did not occur.

This was fine, but it introduced new problems.  Objects designed to be in a fixed position would be able to tear away unless all of the 'Position' and 'Rotation' constraints on the Rigidbody were ticked.  But doing so removed that object's solidity and allowed other objects to pass through it.

After upgrading to Unity 5 and 5.1 though, I had noticed that Unity now treated Rigidbody-equipped objects slightly differently.  So I set about experimenting to learn their new behaviors.

What I found was that objects with RealSense SDK scripts in no longer generated red error messages if the Rigidbody was absent.  Furthermore, removing the Rigidbodies from such objects made the RealSense controls more stable, as the tendency for joints to suddenly jerk during rotational movement had virtually disappeared.

After extensive testing to confirm that this effect was not just chance and it happened consistently, I rebuilt my full-body RealSense-powered avatar to work without any Rigidbodies at all.  The increase in movement smoothness and stability was very significant.

Rigidbodies are a very useful component for certain functions, such as giving objects enhanced collision physics or the ability to fall downward under the influence of gravity.  However, if you do not absolutely need a Rigidbody in a particular object and were just including it to avoid a possible error message, it seems as though you no longer have to have one.

0 Kudos
3 Replies

Have you already tried to add his rigitbody each element?

Honored Contributor III

Every single object in my avatar that had a RealSense script in it also had a Rigidbody, because the error messages in Untiy 4.x had informed me that this was what Unity expected at the time.  And that was therefore a LOT of Rigidbodies, as they were in the arms, legs, torso and all of the facial parts, and each part also often had a number of sub-parts.  The avatar moved fine, but it was vulnerable to occasional random jerking movements, like suddenly bending forward hard or the arm snapping backwards.

Once all of the Rigidbodies were removed, the avatar moved beautifully and the jerking had almost completely gone.  This did not totally surprise me, since the RealSense SDK scripts had always been slightly in conflict with the Rigidbodies.  

For example, if you used an SDK script like TrackingAction then Unity would only listen to the constraint settings in the TrackingAction and ignore any constraints in the Rigidbody unless you ticked the Effect Physics box at the bottom of the TrackingAction's Inspector settings to make the TrackingAction listen to the Rigidbody settings.  And in my case at least, doing so always made the RealSense-controlled object go wrong.

Honored Contributor III

I have created a new demo build of the Rigidbody-less avatar for the forum.  You can download it here (12 mb).

Full control instructions can be found here:

Or just wave your hands around!