Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 36 ยท Physics and Collisions

Forces, Physics Materials and Joints

Apply forces and impulses with AddForce and ForceMode, tune bounce and friction with physics materials, connect bodies with joints, and see the physics math in runnable C# simulations.

You have a Rigidbody and a collider. Now you want it to behave: jump, get pushed by an explosion, bounce like rubber, slide on ice, hang from a rope. This lesson covers the tools that shape how physical objects move: forces, physics materials (bounciness and friction), the gravity setting and joints that connect bodies. It ends with the CharacterController alternative and a few common recipes.

The Unity scripts are read-only. The stand-ins simulate forces, bounces and springs in plain C# so you can see how mass, restitution and damping change the result.

Forces and ForceMode

Rigidbody.AddForce(Vector3 force, ForceMode mode) pushes a body. The mode decides how the number is interpreted, with respect to mass and time:

ForceMode Meaning Use it for
Force (default) Continuous push, uses mass and the step time: acceleration = F / m Engines, wind, steady movement (call every FixedUpdate)
Acceleration Continuous, ignores mass Same push on any object
Impulse Instant change, uses mass: deltaV = J / m Jumps, kicks, explosions, bullets
VelocityChange Instant change, ignores mass Direct speed changes
C#
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class JumpAndPush : MonoBehaviour
{
    [SerializeField] float jumpImpulse = 6f;
    [SerializeField] float moveForce = 20f;
    Rigidbody rb;
    bool jumpPressed;
    float horizontal;

    void Awake() { rb = GetComponent<Rigidbody>(); }

    void Update()
    {
        horizontal = Input.GetAxis("Horizontal");
        if (Input.GetKeyDown(KeyCode.Space)) jumpPressed = true;
    }

    void FixedUpdate()
    {
        rb.AddForce(Vector3.right * horizontal * moveForce);                 // Force
        if (jumpPressed)
        {
            rb.AddForce(Vector3.up * jumpImpulse, ForceMode.Impulse);        // one-time kick
            jumpPressed = false;
        }
    }
}

Read input in Update, apply in FixedUpdate, as described in the game loop. Other force functions: AddTorque (spin), AddForceAtPosition (push at a point, which also rotates), AddRelativeForce (in local axes, for thrusters) and AddExplosionForce(power, center, radius).

A jump that reaches the height you want

Designers like to say "jump 2 meters high". From energy conservation, the launch speed for height h under gravity g is v = sqrt(2 * g * h). With ForceMode.VelocityChange you can set that speed directly, or with Impulse use v * mass.

C#
float jumpSpeed = Mathf.Sqrt(2f * -Physics.gravity.y * jumpHeight);
rb.AddForce(Vector3.up * jumpSpeed, ForceMode.VelocityChange);

Forces and mass: a simulation

This stand-in applies the same force and the same impulse to a light and a heavy body, with the formulas Unity uses for each ForceMode. Watch what mass changes.

C# ForceMode and mass (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.

Force and Impulse give the heavy body less speed; Acceleration and VelocityChange ignore mass. One second of 10 N on 2 kg gives 5 m/s, as Newton predicts. And the jump formula gives about 6.26 m/s for a 2 meter jump.

Physics materials

Collisions need two more numbers: how bouncy and how slippery a surface is. In Unity 6 these live in a Physics Material asset (older versions: Physic Material; the 2D version is Physics Material 2D). Create one with Create > Physics Material and assign it to a collider's Material field.

Setting Meaning
Dynamic Friction Friction while sliding (0 is ice, 1 is rubber on concrete)
Static Friction Friction needed to start moving a resting object
Bounciness 0 means no bounce, 1 means a perfectly elastic bounce
Friction Combine How two materials' frictions merge: Average, Minimum, Multiply, Maximum
Bounce Combine The same for bounciness

Both colliders contribute, and the combine mode decides the result. Typical recipes: a bouncy ball (Bounciness 0.8, Bounce Combine = Maximum), ice (friction 0.02), a "no friction" character capsule (friction 0, Friction Combine = Minimum) so players do not stick to walls.

A frictionless character is a classic fix for "my player sticks to the wall when jumping against it".

Bounciness: a simulation

When a ball with restitution e hits the ground, its vertical speed is multiplied by -e. A ball dropped from 2 meters therefore bounces to e^2 * h.

C# Bouncy ball with restitution (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.

With 0.9 the ball comes back to about 81% of the previous height each time (0.9 squared); at 0.5 only 25%; at 0.0 it simply sticks to the floor.

Gravity

Global gravity is in Edit > Project Settings > Physics > Gravity (default 0, -9.81, 0). Change it in code with Physics.gravity = new Vector3(0, -20f, 0); for a snappier platformer. Per-body control: untick Use Gravity, or apply your own downward force when falling (a stronger fall than rise makes jumps feel better). 2D uses Physics2D.gravity and the Rigidbody2D Gravity Scale.

Joints

A joint connects a Rigidbody to another body (or to a fixed point in the world) with some constraint:

Joint Behavior Example
Fixed Joint Welds two bodies together Glue a hat to a head; breakable
Hinge Joint Rotation about one axis, with optional motor and limits Doors, wheels, swings
Spring Joint A spring pulls toward a distance Elastic ropes, bouncy pickups
Character Joint Ball-and-socket with limits Ragdoll limbs
Configurable Joint Everything, fully tunable Custom constraints

Add a Hinge Joint to a door, set the Connected Body (the frame, or leave it empty to hinge to the world), choose the Axis (0,1,0 for a vertical hinge) and enable Limits to keep it between 0 and 90 degrees. Joints can break under force: Break Force and Break Torque set the thresholds, and OnJointBreak tells you.

A spring in numbers

A spring pulls with force F = -k * x - c * v (stiffness k, damping c, displacement x). This stand-in integrates a mass on a spring so you can see oscillation and the effect of damping.

C# A damped spring (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.

With no damping the mass swings forever; with moderate damping it oscillates and settles; with heavy damping it creeps back without overshooting. Unity's Spring Joint has Spring and Damper fields for exactly these two values.

CharacterController: movement without a Rigidbody

For player characters many games use the CharacterController component instead of a Rigidbody. It is a capsule that you move with code (controller.Move(motion)); it handles slopes, steps and walls, but is not pushed by physics and gives you full control. You apply gravity yourself:

C#
using UnityEngine;

[RequireComponent(typeof(CharacterController))]
public class SimpleController : MonoBehaviour
{
    [SerializeField] float speed = 5f;
    [SerializeField] float jumpHeight = 1.5f;
    CharacterController controller;
    float verticalSpeed;

    void Awake() { controller = GetComponent<CharacterController>(); }

    void Update()
    {
        Vector3 move = (transform.right * Input.GetAxis("Horizontal") + transform.forward * Input.GetAxis("Vertical"));
        move = Vector3.ClampMagnitude(move, 1f) * speed;

        if (controller.isGrounded && verticalSpeed < 0f) verticalSpeed = -2f;     // stay glued to the ground
        if (controller.isGrounded && Input.GetButtonDown("Jump"))
            verticalSpeed = Mathf.Sqrt(2f * -Physics.gravity.y * jumpHeight);
        verticalSpeed += Physics.gravity.y * Time.deltaTime;

        move.y = verticalSpeed;
        controller.Move(move * Time.deltaTime);
    }
}

Choose a Rigidbody when you want pushing, rolling and realistic reactions (balls, vehicles, boxes); choose a CharacterController for precise, responsive humanoid movement.

Quick recipes

  • Explosion: Physics.OverlapSphere plus AddExplosionForce.
  • Wind or current: AddForce in FixedUpdate inside a trigger's OnTriggerStay.
  • Moving platform: a kinematic Rigidbody moved with MovePosition; the player stands on it.
  • Grabbing: a Fixed Joint between the hand and the held body.
  • Slow motion: Time.timeScale = 0.3f and Time.fixedDeltaTime = 0.02f * Time.timeScale to keep physics smooth.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which ForceMode is best for a one-time jump kick that depends on mass?

    Impulse changes velocity instantly and divides by mass.
  2. 2. A ball with Bounciness 0.5 is dropped. How does its rebound height compare to the drop height?

    Speed is multiplied by 0.5 on impact, and height depends on speed squared, so about 25 percent.
  3. 3. Which joint suits a swinging door?

    A hinge allows rotation around a single axis, optionally with limits.
  4. 4. Why give a character capsule a friction-less physics material?

    Zero friction (with Friction Combine = Minimum) lets the capsule slide along walls instead of sticking.

Summary

  • AddForce with Force, Acceleration, Impulse or VelocityChange changes velocity; the mode decides whether mass and time count.
  • Jump speed for a height h is sqrt(2 * g * h).
  • Physics Materials set friction and bounciness; combine modes decide how two surfaces mix.
  • Joints connect bodies: fixed, hinge, spring, character and configurable.
  • Use a CharacterController for precise character control and a Rigidbody for physical objects.

Next: UI Canvas and Layout in Unity