The ultimate guide to physics in game development!

The ultimate guide to physics in game development!

HomeWill HessThe ultimate guide to physics in game development!
The ultimate guide to physics in game development!
ChannelPublish DateThumbnail & View CountDownload Video
Channel Avatar Will Hess2023-02-13 02:45:17 Thumbnail
125,300 Views
In this video, I'm going to cover all things physics in game development in depth. Whether you're a complete beginner and don't know what a force is, or a seasoned game developer who uses physics all the time, I can almost guarantee you'll take something new away from this video. This is the ultimate guide to physics in game development.

The video is divided into 8 different sections and in each section I first go over the basic concept and then show you how it can actually be used. The sections are kinematics, forces, friction, drag, collisions, impulsive forces, rotational kinematics and dynamics, and rigid body component.

In the video I'm using the Unity game engine (specifically Unity 3D), but physics is physics and the concepts and themes will be the same no matter what game engine you use.

Connections:
Project file: https://github.com/WillHess3/Unity-Physics
Full Hammer and Feather Video: https://www.youtube.com/watch?v=oYEgdZ3iEKA

Chapters:
0:00 – Introduction
1:18 – Cutscene
9:44 a.m. – Strengths
7:08 p.m. – Friction
27:14 – Slide
33:38 – Collisions
40:39 – Impulsive forces
46:23 – Rotational movement
56:11 – Rigid body component
1:02:13 – Recap

Kinematics is the branch of mechanics concerned with the movement of objects without reference to the forces that cause the movement. This essentially means that we calculate the motion of an object from an initial set of conditions and the elapsed time. Here we are not going to consider any forces. In game development, we can integrate this concept with kinematic equations. The main kinematic equation and the only one you actually need is xf = 0.5at2 + vt + xi. In Unity we can create a script in C# that has a function with the kinematic equation encoded. This way we can set up initial conditions and throw objects in our video games.

The cinematic is pretty good, but it has some drawbacks. The most important (at least for us game developers) is the fact that managing collisions with cinematics is very difficult because you would have to program everything yourself. It's a much better idea to let the Unity game engine handle all of this and use forces.

A force is simply mass times acceleration, and it can be constantly applied to an object to realistically accelerate it. So we can use forces in our games to simulate things that get faster and faster. The demo I used in the video was of rockets accelerating through space. In Unity we can use forces by calling the AddForce function on our Rigidbody.

Friction is a type of force that resists the movement of two objects in contact and is the force responsible for stopping the movement of objects when no other forces are acting on them. The friction force is equal to the coefficient of friction multiplied by the normal force. At unity, we implement this by adjusting the two friction values in a physical material. the friction values on the two contacting objects are combined in some way to produce the coefficient of friction used in the actual calculation. If no physical material is on an object, it will behave as is, it will have static and dynamic friction of 0.6.

Drag is another resistive force that resists the movement of an object when it is suspended in free fall. The drag force (simplified version) is equal to -bv. In unity however, the drag variable is not equal to b, it is equal to b/m or g/vt where vt is the terminal velocity.

There are 3 main types of collisions: elastic collisions, where no energy is lost, inelastic collisions, where some energy is lost, and perfectly inelastic collisions, where all energy is lost. No matter what type of collision you face, momentum is always retained. We can determine the elasticity of a collision in units using the rebound variable in our physical materials.

Impulsive forces are a way for us to quickly change the momentum of an object. We could realistically do this by having a very high force acting over a short period of time, or we could just make a cheeky move from the game developer and do it instantly. To do this individually, all you have to do is type ForceMode.Impulse as the second argument to the AddForce function. This is probably one of, if not the most important subject of the video.

The rotational movement is divided into two mini-sections, the first being devoted to rotational kinematics. It's exactly the same as classic kinematics, except just using the rotation variables. The next mini-section covers rotational dynamics, focusing primarily on torques. Torque is the measure of the force that causes an object to rotate around an axis. It is equal to the position vector crossed with the force vector, as well as the moment of inertia of an object multiplied by its angular acceleration.

In the last section, I reviewed everything else about the Rigidbody component in Unity.

Subscribe: https://www.youtube.com/WillHessGameDev?sub_confirmation=1

Instagram: https://www.instagram.com/will_hess_yt
Discord: Will Hess (hashtag) 9883

If you have any questions, message me on Instagram or Discord

Please take the opportunity to connect and share this video with your friends and family if you find it useful.