Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MartyG
Honored Contributor III
148 Views

Unity Tip: Reducing Bounce On RealSense-Controlled Objects With Physic Material

Hi everyone,

If your RealSense-controlled objects in Unity bounce off each other when they collide and therefore make precision control more awkward, there is a simple solution.  You can add a component to your object called Physic Material.

A Physic Material basically determines how much friction an object's collider with have when the object that it surrounds collides with another object.  It can be set to very high friction (no bouncing) or very low friction (sliding off like it is touching ice.)  The name Physic Material sounds daunting but it is actually very simple to use.  Below is a guide to adding a Physic Material to your RealSense-powered objects to eliminate bounce-off.

STEP ONE

Create a new Physic Material by going to the 'Assets' menu in Unity and selecting the sub-options 'Create' and 'Physic Material.;

1.jpg

STEP TWO

A new Physic Material file will be placed in the 'Assets' panel.  You will have the opportunity to give this file a name.  We chose to call ours 'Avatar-No-Bounce.'

2.jpg

STEP THREE

Left-clicking on the Material will display its settings in the Inspector panel.  

3.jpg

You can read the full Unity documentation page about the settings here:

http://docs.unity3d.com/Manual/class-PhysicMaterial.html

To summarize:

-  Dynamic Friction and Static Friction define how much friction the object will have when it is moving and when it is stationary.  A value of '0' makes it slide like ice and a value of '1' gives it very high grip.  By default, these settings have a middle-range value of '0.6.'  It is fine to leave these at their default values.

The third option, which we have highlighted in the illustration above, is 'Bounciness.'  If it is set to '0' then the object will not bounce, whereas if it is set to '1' then the object can bounce.  Since our goal is to eliminate bounce-off when our RealSense-powered object collides with another object, we leave it on its default value of '0' to ensure that no bounce will be allowed.

All the remaining settings are left on their default values.

STEP FOUR

Highlight the first of the objects whose collider field you want to eliminate bounce-off in.  The object's settings, including its collider field, will appear in the Inspector panel.

Looking in the 'Material' section of the collider settings, it is set by default to 'None (Physic Material).'  We are going to add our Physic Material component to the collider.

4.jpg

STEP FIVE

Hold down the left mouse button on your Physic Material in the 'Assets' panel, drag it over to the object that you want to apply the material to and release the left mouse button to add it to the object.

5.jpg

You can also apply the Material by drag-and-dropping it onto the 'Material' section of the collider in the Inspector, but the method above is much faster if you have multiple objects to change.

When you check the collider settings again, the 'Material' section will have now updated to show the name of your Material instead of the default 'None' setting.

6.jpg

STEP SEVEN

Drag and drop the Physic Material onto each one of the objects that you want to add the no-bounce physics to.  In our case, that meant adding it to every flesh-piece object of our full-body avatar that might come into contact with something, such as the arms, wrists, torso, legs and feet.  

CONCLUSION

With all of the objects that needed no-bounce qualities updated, we ran our application and moved our avatar arms against each other and against the torso.  There was a noticeable improvement in control precision, with the arms stopping completely when they collided with the opposite arm or with the chest / midriff / stomach.

7.jpg

As always, if you have questions about the process in this guide then please feel free to ask them in the comments!

0 Kudos
0 Replies
Reply