0
0
Unityframework~10 mins

Physics materials (friction, bounce) in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Physics materials (friction, bounce)
Create Physics Material
Set Friction and Bounce
Assign to Collider
Run Physics Simulation
Observe Object Behavior
Friction slows sliding
Bounce affects collision rebound
This flow shows how a physics material is created, configured with friction and bounce, assigned to an object, and then affects the object's physical behavior during simulation.
Execution Sample
Unity
var mat = new PhysicMaterial();
mat.dynamicFriction = 0.5f;
mat.bounciness = 0.8f;
collider.material = mat;
This code creates a physics material, sets friction and bounce, and assigns it to a collider.
Execution Table
StepActionVariable/PropertyValueEffect
1Create PhysicMaterialmatnew PhysicMaterial()Material object created
2Set dynamicFrictionmat.dynamicFriction0.5Moderate friction set
3Set bouncinessmat.bounciness0.8High bounce set
4Assign material to collidercollider.materialmatCollider uses new material
5Run simulationObject behaviorSliding slows, bounces on collisionFriction and bounce affect physics
6Object hits surfaceBounce effectRebounds with 80% energyObject bounces back
7Object slidesFriction effectSpeed reduces due to 0.5 frictionObject slows down
8Simulation ends--Physics material effects observed
💡 Simulation ends after object interaction with surface using assigned physics material
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
matnullPhysicMaterial instancedynamicFriction=0.5bounciness=0.8Assigned to colliderUsed in simulation
collider.materialnullnullnullnullmatmat
Key Moments - 3 Insights
Why does the object bounce back after hitting the surface?
Because the physics material's bounciness is set to 0.8 (see execution_table step 3 and 6), the object rebounds with 80% of its collision energy.
How does friction affect the object's sliding speed?
The dynamicFriction value of 0.5 (execution_table step 2 and 7) slows down the object's sliding by reducing its speed over time.
What happens if the physics material is not assigned to the collider?
Without assignment (step 4), the collider uses default physics settings, so friction and bounce effects from the material won't apply.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what property is set and what is its value?
AdynamicFriction = 0.8
Bbounciness = 0.8
CdynamicFriction = 0.5
Dbounciness = 0.5
💡 Hint
Check the 'Variable/Property' and 'Value' columns at step 3 in execution_table.
At which step is the physics material assigned to the collider?
AStep 4
BStep 5
CStep 2
DStep 1
💡 Hint
Look for the action 'Assign material to collider' in execution_table.
If dynamicFriction was set to 0, what would happen to the object's sliding speed?
AIt would bounce higher
BIt would slow down faster
CIt would not slow down due to friction
DIt would stop immediately
💡 Hint
Refer to key_moments about friction effect and execution_table step 7.
Concept Snapshot
Physics Materials in Unity:
- Create PhysicMaterial object
- Set dynamicFriction (slows sliding)
- Set bounciness (controls bounce)
- Assign material to collider
- Physics engine uses these during simulation
- Friction reduces speed, bounce rebounds object
Full Transcript
This visual execution shows how to create and use physics materials in Unity. First, a PhysicMaterial object is created. Then, its dynamicFriction and bounciness properties are set to control sliding resistance and bounce behavior. The material is assigned to a collider component on an object. When the physics simulation runs, the object interacts with surfaces using these settings. Friction slows the object's sliding speed, and bounciness causes it to rebound after collisions. The execution table traces each step, showing variable changes and effects. Key moments clarify why bounce happens and how friction works. The quiz tests understanding of property settings and their impact on physics behavior.