2. Forces

What is a force?

  • In physics, a force is an influence ("push or pull") that can change the motion of an object

  • Force causes an object to accelerate

    • This in turn changes the object's velocity
    • ...which changes the object's position
  • Brackeys video: Forces

Force vector

    • the unit of force is Newton ()
    • force equals mass times acceleration
    • the force is a vector
    • so it not only has a magnitude, but also a direction

Note about forces in games

  • In games, we're generally more interested in the gained acceleration than the actual force
    • The bigger the mass, the smaller the acceleration!

Multiple forces

Force vectors can be added together to acquire the total force:

Torque

  • Torque is the rotational equivalent of linear force
  • Torque "makes things turn"
  • In simplified terms, torque is force times length of the lever arm
  • Unit of torque is Newtonmeter ()

Torque... vector?

  • More precisely, torque is a vector, produced by a cross product between the lever arm vector and a force vector
  • Note: Cross product between two vectors produces a new vector perpendicular to both the two

Forces in Unity

  • In Unity, forces are applied by the physics engine
    • See: Physics
    • We need a Rigidbody component to apply forces to a GameObject.
  • If you want more control, you can also create your own code e.g., for simulating planets in a star system

Exercise 1. Forces

Create a 3D scene where a player character can push around rigid bodies by applying a force to them.

How would you calculate the direction of the force?

Hint: you need to use the concepts of distance and normalization.

Reading & Watching