Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Physics Materials and Effectors | Fundamentals of Components in Unity Inspector
Unity for Beginners

bookPhysics Materials and Effectors

Deslize para mostrar o menu

So far, our player falls thanks to gravity and stops when it reaches a platform because of colliders. But when it lands, it just stops and that doesn't feel very satisfying.

Fortunately, Unity lets us add bounciness to objects using a Physics Material 2D.

Step 1: Create a Physics Material 2D

  1. Select the platform object and look at its collider. There's a slot for a Physics Material 2D;
  2. It's good practice to keep things organized, so create a folder for physics materials in your Project tab;
  3. Right-click inside the folder, go to Create → 2D → Physics Material 2D;
  4. Name your material something descriptive (e.g., PM_platform).

Step 2: Adjust Physics Material Properties

Select the physics material and look in the Inspector. Two important values:

  • Friction: determines how slippery a surface is;
  • Bounciness: determines how much objects bounce when they hit it.

Step 3: Assign the Physics Material

  1. Select the platform object;
  2. Drag the physics material into the Physics Material 2D slot on the collider.

Now your platform will use the material's properties.

  • Set bounciness = 1 → the player bounces back to the starting height;
  • Set bounciness < 1 → the player bounces lower each time and eventually stops;
  • Set bounciness > 1 → the player bounces higher each time, endlessly.

For now, we'll use 1.

Step 4: Prevent Bouncing Problems with the Platform Effector

Sometimes, when the player tries to bounce up onto another platform, they hit the bottom instead of landing on top.

Unity provides a fix: the Platform Effector 2D.

  1. Select the platform object → Add ComponentPlatform Effector 2D.
  2. A warning will appear. Go back to the platform's collider and check Used by Effector;
  3. Now, when the player moves up through the platform from below, it won't block the bounce, but it will still land properly from above.

Step 5: Adjust the Player Collider if Needed

Sometimes the player might appear to bounce off a platform even if their feet aren't aligned with it.

  • This happens if the player's collider is too wide;
  • Make the collider narrower so it matches the width of the player's feet;
  • Now the bounce only happens when the player actually lands on the platform.

Step 6: Experiment!

Physics Materials and colliders are very flexible.

  • Try different bounciness values;
  • Try different gravity scales and linear damping values;
  • Resize and reposition colliders.

This lets you create all kinds of gameplay effects and makes your endless jumper feel alive and satisfying.

Your player can now bounce, land, and interact realistically with platforms, a fun foundation for more complex movement and mechanics.

1. What does the Bounciness value in a Physics Material 2D control?

2. Why do you use a Platform Effector 2D on a platform in Unity?

3. What should you do if the player bounces off a platform even when their feet don’t touch it?

question mark

What does the Bounciness value in a Physics Material 2D control?

Selecione a resposta correta

question mark

Why do you use a Platform Effector 2D on a platform in Unity?

Selecione a resposta correta

question mark

What should you do if the player bounces off a platform even when their feet don’t touch it?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 4

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 2. Capítulo 4
some-alt