Game Physics - Introducing Gravitation & Rotation in Unity
4.7 (447 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
15,452 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Game Physics - Introducing Gravitation & Rotation in Unity to your Wishlist.

Add to Wishlist

Game Physics - Introducing Gravitation & Rotation in Unity

Step-by-step tutorial on how to create a basic rigid body motion physics from scratch. Taught in C# using Unity 3D free.
Bestselling
4.7 (447 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
15,452 students enrolled
Created by Ben Tristem
Last updated 9/2016
English
English
Learn Fest Sale
Current price: $10 Original price: $95 Discount: 89% off
3 days left at this price!
30-Day Money-Back Guarantee
Includes:
  • 5 hours on-demand video
  • 4 Articles
  • 4 Supplemental Resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Translate new laws of physics to code.
  • Understand how game engine physics works.
  • Extend the capabilities of Unity 3Ds physics engine.
  • Transfer this knowledge to other game engines.
View Curriculum
Requirements
  • You need to be comfortable with Unity 3D
  • You need to be comfortable with C# scripting.
  • You should be able solve basic algebra equations.
Description

Learn to build your own game physics engine. By the end of this mini-course course you will have gained confidence in translating theories of physics into working game code.

I will be teaching using Unity 3D free as the example game engine. I expect you to have some experience with both Unity 3D, and C# before starting this course. If you don't then check out my Complete Unity Developer course.

Why would you take this course?

  1. To understand game physics better.
  2. Practice creating your own physics components.
  3. Improve your knowledge of Newtons Laws of Motion.

There is a thriving community, and we will be providing our usual world-class support that our students have come to expect.

Note: access to this course comes with an optional, free community site where you can share games and 3D models, as well as connect with other students.

See you in there!

Who is the target audience?
  • This course is ideal for you if you're running into the limits of your game engine's physics.
  • If you are not confident in how your game engine's physics works "under the hood", this course will give you that insight.
  • This course is probably not for you if you're a physics PhD, who is already confident in coding!
Students Who Viewed This Course Also Viewed
Curriculum For This Course
Expand All 45 Lectures Collapse All 45 Lectures 05:41:18
+
Introduction & Setup
5 Lectures 13:02

IN THIS VIDEO...

What you'll need to start

  • A Mac or PC that can run Unity 3D or similar.
  • You can use another game engine if you like.
  • Some coding experience (see sample code).
  • Some understanding of mechanics & units.
  • Confidence in basic algebra.


Preview 03:10

IN THIS VIDEO...

  • An overview of the interface
  • How to search for things
  • Summary
Welcome To The Course
01:48

IN THIS VIDEO...

  • Download, Install & Register Unity

SOME USEFUL LINKS...

  • Unity - Download Archive

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Installing Unity 3D
02:54

Section Summary
03:45

Section End QUIZ
5 questions
+
Newtons Laws of Motion
18 Lectures 02:46:52

In this section we will be dealing with a rigid body, and the effect of forces on it.

  1. Unbalanced forces lead to accelerations.
  2. Accelerations lead to a change in velocity.
  3. Velocity determines the change in position.

We will be working backwards through this list, starting with position and eventually creating components to model the effect of various forces on our game object.

Introduction To Section 2
01:26

Section 2 Assets
00:03

Section Notes PDF
13 pages

IN THIS VIDEO…

  • Introducing Sir Isaac Newton
  • Newton's First Law
  • About the FixedUpdate() loop
  • Updating transform.position

SOME USEFUL LINKS...

  • Using FixedUpdate() - Execution Order of Event Functions

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Preview 12:40

IN THIS VIDEO...

Create A Force List

  • using System.Collections.Generic;
  • Create a public list of forces, forceVectorList;
  • Create AddForces () so sum the forces.
  • Debug.LogError () if we have a net force.
  • Otherwise continue to update the position.
Summing The Forces
11:13

IN THIS VIDEO...

  • 2nd Law Defined
  • Write Code For Acceleration
  • Publicly expose float mass
  • Create UpdateVelocity () method
  • Modify velocityVector every FixedUpdate
  • Remove Debug.LogError() code
Newton's 2nd Law
08:48

IN THIS VIDEO...

  • Defining Newton's Third Law.
  • Examples of why it's important to consider.
  • Introducing our trail drawing code.
  • Switching trail direction.
  • Recap of Newton's laws
Newton's 3rd Law
08:32

IN THIS VIDEO...

  • What we're trying to achieve.
  • Why it's important to get this “right”.
  • Re-orgainse list iteration for variable forces.
  • Bring DrawTrails.cs into PhysicsEngine.cs.
  • Move the forces into separate components.
Physics Engine Architecture
15:36

Mid Section QUIZ
5 questions

DOWNLOAD Unity Project
00:11

IN THIS VIDEO...

  • About Units and Dimensions.
  • Why it's worth thinking about them.
  • Where to annotate our units.
  • Prepare our RocketEngine.cs class.

SOME USEFUL LINKS...

  • SI base unit - Wikipedia, the free encyclopedia

(NOTE YOU CAN CLICK THESE LINKS BELOW)

SI Units & Dimensions
10:52

IN THIS VIDEO...

  • The thrust of a rocket engine.
  • Modelling rocket engines and fuel burn.
  • An introduction to “delta V”.

SOME USEFUL LINKS...

  • Rocket engine - Wikipedia, the free encyclopedia

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Rocket Science 101
16:41

IN THIS VIDEO...

  • Review the universal gravitation equation*
  • Create a method for it in Unity.
  • Check we get realistic force values.

SOME USEFUL LINKS...

  • Gravitational constant

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Modelling Gravity
16:01

IN THIS VIDEO...

  • Setup a football field “on Earth”.
  • Test gravitation matches real values.
  • Explore parabolic flight.
  • Set scene for air resistance.
Back Down To Earth
12:48

IN THIS VIDEO...

  • Design a simple formula for air resistance.
  • Create an Air Drag component.
  • Test flight against reference ball.
  • Tweak to get similar results to Unity's engine.

SOME USEFUL LINKS...

  • Drag (physics)

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Air Resistance
13:09

IN THIS VIDEO...

  • Expand on Unity's script execution order*
  • Demonstrate our bug at “high” speeds.
  • Show how this relates to fixed update time.
  • Move Universal Gravity to separate object.

SOME USEFUL LINKS...

  • Execution Order of Event Functions

(NOTE YOU CAN CLICK THESE LINKS BELOW)

Script Execution Order
10:33

IN THIS VIDEO...

  • Make a simple hit-the-target game.
  • Add a cylinder to represent a rocket launcher.
  • Write Launcher.cs class.
Making A Simple Game
19:51

IN THIS VIDEO...

  • Re-introduce Universal Gravitation.
  • Review the overall structure of what we've done.
Finishing & Tidying Up
05:44

WHAT YOU'VE LEARNT...

  • Basic physics engine architecture / trade-offs.
  • A foundation in Newton's Laws of Motion.
  • Dimensional checking as a tool.
  • How to distill information from Wikipedia etc.
  • How to create components for various forces.
Section 2 Wrap-Up
02:43

Section End QUIZ
6 questions
+
Simple Rotation
12 Lectures 01:26:58
Introduction To Section 3
01:57

  • Section Assets Pack
  • Previous section project, for Magnus Effect
Section 3 Assets
00:04

Section Notes
8 pages

  • The limitations of spinning objects in Unity 5.
  • Why unstable rotation doesn't evolve.
  • How to model unstable rotation in game physics.
Unstable Rotation In Unity 5
08:37

  • Roughly what is an inertia tensor (I)?
  • Unstable intermediate axis
  • How Unity Calculates I
  • Calculate I for your phone
  • Predict it's unstable axis
Introducing Inertia Tensors
13:39

  • How about if two axis are equal?
  • Try it with a spinning cylinder.
  • Calculate the moment of inertia.
  • Render vs. collider mesh influence.
Calculating Moment Of Inertia
11:35

  • NOT the same as Intermediate Axis Theorem.
  • How to calculate I for compound objects.
  • Think of a discus thrower.

http://en.wikipedia.org/wiki/Parallel_axis_theorem

Parallel Axis Theorem
10:19

  • A recap of Newton's laws of motion.
  • How these relation to rotation.
  • Important differences.
  • Why we're jumping in the deep end!
“Newton’s Laws Of Rotation”
08:45

  • How to use Unity's AddTorque() method.
  • How Inertia Tensor affects rotation.
  • Comparing the rotation of two objects.
Applying Torque To Rigidbodies
11:02

  • What a cross product is.
  • Why they are so useful.
  • Using WolframAlpha to calculate.
Vector Cross Products
07:13

  • What the Magnus Effect is.
  • How we can approximate ball flight with it.
  • Using Vector3.Cross in Unity.

The code you need is below...

public float magnusConstant = 1f;

private Rigidbody rigidBody;


void Start () {
rigidBody = GetComponent<Rigidbody> ();
}


// Update is called once per frame
void Update () {
rigidBody.AddForce (magnusConstant * Vector3.Cross (rigidBody.angularVelocity, rigidBody.velocity));
}

The Magnus Effect
11:10

Section 3 Wrap-Up
02:37
+
Making Contact
10 Lectures 46:25
Introduction To Section 4
02:40

Your Section 4 Assets
00:04

Your Section Notes
7 pages

  • Why friction is so important.
  • About physics materials and friction.
  • How static and dynamic friction relate.
  • Using the Friction Direction 2 setting.
  • Limitations of Unity's friction, and to improve it.
An Overview Of Friction
08:25

  • Welcome “Mu-s”, the coefficient of static friction.
  • What the static friction coefficient means.
  • How this coefficient relates to slope angle.
  • Two triangle trigonometry take-home tricks.
  • Testing critical angle in Unity Editor.
Static Friction & Critical Angle
10:35

  • Discover slipping angle.
  • Try three different static friction coefficients.
  • About rolling, and “impulsing” the block.
  • Generally horsing around with blocks and slopes.
Make A Friction Test Rig
08:55

  • Why we care about friction combine.
  • The limitations of Unity's model.
  • How friction combine precedence works.
Friction Combine In Unity
03:46

  • What is dynamic friction.
  • How it relates to terminal velocity on a slope.
  • A look at some Stribeck curves.
About Dynamic Friction
05:32

  • What the Friction Direction 2 setting does.
  • How it might be useful.
  • A note on using unit vectors.
  • Friction Direction 2 doesn't work in Unity 5!
How Friction Direction 2 Works
03:43

Congratulations and how to continue your learning.

Wrap-up & Next Steps
02:45
About the Instructor
Ben Tristem
4.7 Average rating
44,944 Reviews
230,257 Students
10 Courses
Best-selling Instructor, Game Developer, Online Entrepreneur

Hi, I'm Ben. I have a degree in computing from Imperial College London, and a physics diploma from the Open University.

I started working for myself at the age of 15, and never looked back. I explored careers as varied as being a commercial pilot, stunt-man, rock climbing instructor, and more. None of these provided a continued challenge, and stable income in the same way technology does.

After building and selling a home computer support business, I became an angel investor and business mentor here in Cambridge UK. I fell in love with teaching game development through one of my investments, and I now spend all of my time sharing my passion with people like you.

I can't wait to help you experience the fulfilment, and financial freedom, that having a deep understanding of technology brings.

So why not start learning to make games with me and my team now?

See you soon!

Ben