Game Development Reference
In-Depth Information
Classified intel
In this step, we create the Player physics 2D material object and assign it to Box Collider
2D for our Player game object. So, what is Physics2D Material ? If we take a close look at
the inspector of the Physics2D Material object, we will see that there are two properties:
Friction and Bounciness . Friction is the force that resists the relative motion of this col-
lider. Bounciness is the degree to which collisions rebound from the surface ( 0 means no
bounce and 1 means perfect bounce with no loss energy).
Note
For more details of Physics2D Material , visit http://docs.unity3d.com/Documentation/
Components/class-PhysicsMaterial2D.html .
We've set Friction for the Player physics 2D material to 1.2 , which means that we will
use 1 to calculate the coefficient of friction in this collider. If we remember the previous
step, we also assigned the Edge and Ground physics 2D material object on our platform
and edge. If we take a look at the Ground physics 2D material's Friction value, we will
see that the value is equal to 1 . This means that when we stop moving our character, there
won't be any much force left to push the character forward.
On the other hand, the Edge physics 2D material object has the Friction value set to 0 ,
which means that there is no friction in this collider. So, it will result our character not be-
ing able to stop on this collider. This helps us to prevent our character from getting stuck on
the edge of the platform, as shown in the following screenshot:
Search WWH ::




Custom Search