The Ultimate Guide for Physics in Game Development!

preview_player
Показать описание
In this video, I am going to thoroughly go over everything about physics in game development. Regardless of whether you are 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 that you will take something new away from this video. This is the ultimate guide for physics in game development.

The video is broken up into 8 different sections and in each section, I first go over the core 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 the Rigidbody Component.

In the video, I use the unity game engine (particularly unity 3D), but physics is physics and the concepts and themes will be the same regardless of the game engine you use.

Links:

Chapters:
0:00 - Intro
1:18 - Kinematics
9:44 - Forces
19:08 - Friction
27:14 - Drag
33:38 - Collisions
40:39 - Impulsive Forces
46:23 - Rotational Motion
56:11 - Rigidbody Component
1:02:13 - Recap

Kinematics is the branch of mechanics concerned with the motion of objects without reference to the forces which cause the motion. This basically means that we are calculating an object's motion from some initial set of conditions and the time elapsed. Here we are not going to consider any forces. In game development, we can incorporate this concept with the kinematic equations. The main kinematic equation and the only one you really need is xf = 0.5at2 + vt + xi. In Unity, we can make a script in C# that has a function with the kinematic equation coded in. This way we can set up some initial conditions and launch objects in our video games.

Kinematics is pretty good, but there are some drawbacks. The biggest one (at least for us game developers) is the fact that handling collisions with kinematics is very difficult because you would have to program it all yourself. It is a much better idea to let the unity game engine handle all of that stuff and you use forces.

A force is a just a mass times an acceleration, and they can be constantly applied to an object to accelerate it realistically. We can use forces in our games this way to simulate things that are constantly getting faster. The demo I used in the video was rockets accelerating forward in space. In Unity we can use forces by calling the AddForce function on our Rigidbody.

Friction is a type of force that resists the motion of two objects in contact and is the force responsible for making objects stop moving when no other force acts on them. The force of friction is equal to the coefficient of friction times the force normal. In unity we set this up by adjusting the two friction values in a physics material. the friction values on the two objects in contact get combined somehow to produce the coefficient of friction used in the actual calculation. If no physics material is on an object it will behave as is it has a static and dynamic friction of .6

Drag is another resistive force that resists the motion of an object as it is suspended in free fall. The force of drag (simplified version) is equal to -bv. In unity however the drag variable doesn't equal b, it equals b / m or g / vt where vt is 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 are facing, momentum is always conserved. We can determine a collisions elasticity in unity by using the bounciness variable in our physics materials.

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

Rotational motion is broken up into two mini sections with the first being on rotational kinematics. It's exactly the same as regular kinematics except just using the rotational variables. The next mini section is on rotational dynamics mainly just focusing on torques. Torque is the measure of the force that causes an object to spin around an axis. It equals the position vector crossed with the force vector, and also an object's moment of inertia times its angular acceleration.

In the last section I just went over everything else about the Rigidbody component in Unity.

Discord: Will Hess(hashtag)9883

If you have any questions DM me over Instagram or Discord
Рекомендации по теме
Комментарии
Автор

CORRECTIONS:
- gravity on earth’s surface, g, is 9.8 m/s^2 and not -9.8m/s^2. The negative comes from saying that it is “pulling you down” and not “pushing you up”
- a normal force is not just the force that counters gravity. In a Goldilocks scenario where the object is on a flat surface, it is, but normals are perpendicular to the surface, not just straight up in the air.

If you find more leave a comment and I’ll add it here!

WillHessGameDev
Автор

"thanks to Galileo and his balls.." lmao

mehmeh
Автор

My man just condensed an entire highschool physics semester into a 1h video... good work! I wish this was the pacing we had at school xD

maxfrobin
Автор

What the actual F***...this is the most explanatory and comprehensive video explaining such complex topics I have ever seen. Extremely good job!

Nightwulf
Автор

I gave up on physics in highschool since our teacher wasn't qualified to even teach. This video is honestly so helpful.

kizlso
Автор

I dropped physics 1 in college and went to a different science for my CS degree because I knew the topics conceptually, but my mathematical understanding of them were lacking (also was working full time and taking classes full time, so that didn’t help). This video alone taught me how to understand them on a deeper mathematical level much better than my professor ever did. Thanks boss

ItsStaffDaddy
Автор

Thanks for pouring so much energy into this video. Must have taken a while to produce. For me this is a super helpful refresher on physics in general and you did a great job relating it to game dev and Unity here. Thanks and subscribed! :)

DrZwieback
Автор

Started looking into math and physics yesterday to buff my gamedev - will be checking this out, thanks for your effort boss!

nikjeewon
Автор

Great video! Just wanted to mention a small funny moment. You said at 20:55 that static friction should always be greater or equal to dynamic friction, but a few seconds later when you show the unity settings, you entered dynamic 0.25 and static 0.2 friction.
Apart from that, keep up the good work!

nenadjovanovski
Автор

Finally a truly informational video. Instant sub.

marmikemp
Автор

Pro vectors tip:
If you had problems calculating the angle of a vector from 0 to 360° (or 2π rad), it's probably because you used atan(y/x) instead of the 2-argument arctangent: atan2(y, x) which takes the two variables.
Dividing y/x before passing it to the arctan function actually loses information about directionality, for example -1/1 = 1/(-1). But (1, -1) and (-1, 1) are not the same vector and don't represent the same angle.

LRTOTAL
Автор

Can't thank you enough for this, you gained my sub brother. I was collecting resources online so I can understand how to implement things. I stumbled upon your video (haven't finished it yet, but the sections you've covered with demos are tremendously useful.) and now everything seems a lot more in place.

dannydoo
Автор

best, clearest explanation of this topic I have found yet

joshparrott
Автор

Great physics refresher video. Not sure what all the videogame stuff is about :D

ArchonLicht
Автор

This was invaluable to me as I am learning game development. I greatly appreciate this lecture/tutorial! World

jermaineallgood
Автор

19 minutes in and my brain is fried. i'll come back tomorrow

daka.notatp
Автор

Hey man, I just saw your video and it was one of the best about physics for game dev, pretty sure that you have spent huge amount of efforts into it. The knowledge was comprehensive and actually being all the knowledge a university student will learn in the first 2 years, which later apply for the game dev. And just want to say you did a great job, really appreciate your work !

martinthexr
Автор

Your video is really helpful, I was stuck with creating friction for my game for the last few days then found out your video then I skipped to the 'friction' part and your explanation help me in just 5 seconds to figure it out.

congnam
Автор

Rock solid and practical, thank you for putting this out there for everyone!

oldmankatan
Автор

BROOOO, idk why but that was


No CAP but you explained some concepts in such a way where most professional teachers also fails, SEGGZYYYY

arxsh