Это видео недоступно.
Сожалеем об этом.
The Ultimate Guide for Physics in Game Development!
HTML-код
- Опубликовано: 14 авг 2024
- 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:
Project File: github.com/Wil...
Full Hammer and Feather Video: • Apollo 15 Hammer-Feath...
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.
Subscribe: www.youtube.co...
Instagram: / will_hess_yt
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!
It depends on your choice of coodinate system axes. Choose your x coordinate to increase downwards and the equation for a falling object is going to become s=s0+v0t+½gt² with a positive g (a=g). Choose the opposite direction and you will need a negative value.
@@HoSza1 X coordinate?
@@HoSza1I just like to think about it like this, things get thrown in parabolas that open downwards. In order for a parabola to open downwards the term that has t^2 has to be negative so I just throw a negative in there. I usually don’t get too fussed about those negatives because using common sense works fine (until it doesn’t lol).
Also don’t for get the (1/2) with your at^2 term, or else the integral gods will be sad.
You definitely want to do v squared for fluid forces. But honestly if you have an idea of the motion you want to replicate you are probably best off to keep the full equation and just place in imaginary values for certain prams. The cross section area is easily estimated, and so with that you are left with two parameters; density and drag coefficient. Put the density to the fluid you want it to behave like and put the drag coefficient such as to match whatever you want like terminal velocity or something. That way when you put other elements into your environment they all behave consistently.
It's not the leaning tower of pizza. It's the leaning tower of Pisa. "Pee-sa" 😉
"thanks to Galileo and his balls.." lmao
That caught me so off guard 😂 💀
And tower of pizza
😆😆Got me rolling
Was coming to the comments to write that lmao
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
Lol I guess so! Thanks for watching!
What the actual F***...this is the most explanatory and comprehensive video explaining such complex topics I have ever seen. Extremely good job!
Thank you so much!
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
Thank you so much! I’m glad I could help!
Either Physics 1 was way more complicated than this, you weren't paying attention, or your professor *sucked* at teaching.
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! :)
Thank you so much for watching and subscribing!!!
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.
Thank you for these tips!
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!
Yeah, I was probably just picking random numbers for that… thanks for catching that and watching!
Started looking into math and physics yesterday to buff my gamedev - will be checking this out, thanks for your effort boss!
No problem!
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.
No problem, and thanks for subscribing!
Finally a truly informational video. Instant sub.
Thank you so much!
I gave up on physics in highschool since our teacher wasn't qualified to even teach. This video is honestly so helpful.
Glad it was helpful!
19 minutes in and my brain is fried. i'll come back tomorrow
Physics is a tricky subject and can get confusing fast. Here is some (not very good) words of encouragement my physics teacher would say, “all physics is, is F=ma, and everything else comes from that”
At about 29:50, you are comparing an estimated terminal velocity between a 5kg mass and a 10kg mass while using the same b coefficient, coming up with Terminal velocities of 612.5 m/s and 1225 m/s respectively.
However, given similarly shaped and density object of different masses will not share the same cross-sectional areas when moving through a fluid medium. If object 2 has twice the mass of the first object, then the cross-sectional area is about 58.74% more than object 1.
(Or more simply, an object of 8× the mass will have 4× the cross-sectional area, all else being equal).
So, in part, you are correct in that it didn't get close enough to the terminal velocities in Galeleo's testing, but also the change in cross-sectional area was not taken into account when using a constant b term.
Hi! I really liked your guide! I understood about 10% the first time. I'll watch it again to understand more. Thanks for making this for beginners.I'm working as a full-stack developer for years, but I dream to be a game dev once a while. Your guide is a great help for my projects.
Do you also live-stream your work? I would love to see you doing game development live. Thanks again for your great work!
Hi! First of all, thanks for watching and leaving a comment. I really appreciate it. And about the live streaming, I have never done it but I have always had that idea in the back of my head once the channel takes off a little bit more. My thing is that if I did it now it would be a lot of work on my end for like probably 10 people to watch, so it doesn’t seem worth it to me to do it now. But I’m glad you would watch live!
Great physics refresher video. Not sure what all the videogame stuff is about :D
Drag should be proportional to velocity squared. The drag equation clearly states v^2.
I 100% agree with you on that and I have no idea why it isn’t. My physics textbook used that equation with -bv as an equation for any “resistive force”. They just said it was air resistance, which confused me because I knew there was this long formula for it. I was messing around with reading velocity data for different falling objects in unity and low and behold they use this dumbed down version of drag too! Idk why it can’t be dumbed down but keep the square…
@@WillHessGameDev Perhaps what they mean is rolling resistance or friction based resistance, they scale linearly with velocity.
it might help someone, so i’ll mention it. velocity is speed AND direction, whereas speed does not regard direction
Precisely speed is the scalar and velocity is the vector. Speed is also the magnitude of velocity.
Thanks for putting this up because I think I just said they were similar in the video and didn’t elaborate oops 🤦♂️
you know what is funny, only in english :)
Rock solid and practical, thank you for putting this out there for everyone!
No problem! Thanks for watching
I rarely find video tutorial about physics for game Dev, I'm looking forward to more physics stuff for game dev if there's more to it or probably separate videos for each topic with additional or much detailed tutorial regardless this one is still good.
A good tip when it comes to calculating things for working with kinematics is offsetting.
Don't bother calculating things in their own reference frame, do all you calculations assuming more favorable conditions (start at the origin of the axis, and move along a single axis, and not along some combination of a couple of axes).
Then add the appropriate offsets to the results, this back and forth conversion may not be the most efficient, but it will help your calculation a lot.
For example, having something move on a circle goes something like this: *(x₁ + x)² + (y₁ + y)² = R²*
Where x₁ and y₁ are constants, the position of the circle's center.
But that's a hard calculation, so we offset to 0 instead.
Assume x₁ and y₁ are 0, you get a simpler equation: *x² + y² = R²*
Then whatever result you get, you add the offset to that, and you're golden.
yes that is a very good tip!
The equation of a circle centered on the origin is x^2+y^2=R^2
x^2*y^2=R^2 gives an odd star-shape. I'm sure it has a name but I can't be bothered to look it up right now.
Edit:
From this the general equation is (x - x1)^2 + (y - y1)^2 = R^2
Where the centre is at (x1,y1).
@@alansmithee419 Yes, my bad.
I'll edit it.
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 !
Glad you liked it!
Really useful video. I don't know how accurate it is but I learned a lot :D Thanks for doing this and I hope you'll get more views :)
Thank you!
Liked, subscribed, shared, and commented...
If there were anything else that I could do, I would bro, this is considered a piece of art, the art of making concepts easy to understand, without cutting any part of it.
Awesome work man, appreciate the time and energy you put into this video ❤
Much appreciated!
Thanks a lot!! Just watched your pixel art video and i need to say I'm loving your channel, bro!!
Glad you enjoy it!
I can't express just how important this video is for an aspiring game developer who kinda slept through his physics classes ngl.
Glad it helped!
Now this is S tier content! Tnx so much! May your channel blow up!
Thanks!
I am been trying to make a simple version of unity physics (because I do not need all the realistic stuff). I did not realize that physics is that complicated.
It is just a LOT of math. If you don’t mind me asking, is the “simple version” in unity? Or is it like a separate physics engine? I say that because if you are trying to make a simple physics engine you have one very hard topic to learn, collision detection and coming up with a good algorithm for that.
If you were talking about just using physics in unity to make stuff move around, I’ll give you the TLDR.
- use fixed update for forces that act over time
- use forceMode.Impulse for forces that happen instantly (or if you aren’t concerned about realistic-ness you can use forceMode.velocityChange)
-change an object’s mass to make it more or less “influenced” by the force you act on it
Hope that helped and feel free to ask any questions!
@@WillHessGameDev I am gust trying to make a light weight version of the unity physics. All the "physics" that my "physics engine" will have is Gravity, Collision Detection (Using unity colliders, and Physics.Overlap____), ground checking, fake velocity, fake drag, slopes. the drag, and velocity is even more simple then what you explained in the video.
I amm planning on adding force when colliding with things though.
Cool, well if you get stuck feel free to reach out!
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.
Glad it helped!
Great video! One minor mistake is saying that -9.8m/s^2 is g. g is 9.8 m/s^2, so -9.8m/s^2 is -g.
Thanks for the correction! I always mess up with that one lol.
This has to be the pettiest correction ever...
When people say g = -9.8m/s/s, it's beyond obvious that it's in reference to the 2nd derivative of displacement relative to the normal of the surface of the Earth in the Newtonian paradigm; ie. falling. The negation is clearly using the reference frame of someone stood on the surface of the Earth for the scalar; a very human perspective.
So unless the usage is a constants library for onboard interplanetary exploration navigation software then there's no reason not to glance at it, understand what's meant and roll with it.
@@davidmurphy563 I know what's meant, but it is something my physics professor would mark us down on. For a video about correcting common mistakes in game physics, I figured it was worth mentioning that g is an unsigned value.. I did say it was minor, after all.
I’m going to be honest. When I heard your voice, i thought this was going to be another uniformed, amateur game dev video by some teenager. But I was completely wrong, you absolutely killed it! Great info, succinctly explained. Great job!
Thanks! I appreciate it!
very usefull information, underrated video
Glad you think so! Make sure you share it with others who you think will find it useful so it will become un-underrated!
Big shout-out to Galileo and his balls.
Exactly people always credit Galileo but they forget to credit his balls too! Justice for Galileo’s balls!
Such a gem, hope you cover more physic topic in the future
As a curiosity more than a correction, gravity decreases slightly the higher you are from earth's surface. Gravity is partially defined by the distance between the center of 2 objects but since earth's radius is very large we can discard any height (distance from earth's surface) and say that gravity is 9.8 mostly always when working with relatively small units.
Very true. g = GM/R^2 where G is the gravitational constant and R is the distance to earths center, and mass is the mass of earth. Plugging stuff in at sea level I believe is where the 9.8 comes from!
@@WillHessGameDev It is indeed!
This kid is God sent to me …. Thanx buddy …. U r a genius …
It’s exactly what I needed… thanx
BROOOO, idk why but that was SEEXYYYYYYY
No CAP but you explained some concepts in such a way where most professional teachers also fails, SEGGZYYYY
lol thanks
That's my friend is a golden standard of the gamedev content
Dude sounds like Michael Reeves if he hit puberty
Thanks… I think…
The reason a bounciness of 1.0 causes the ball to bounce higher over time is because of how collision detection works. The ball is simulated with a fixed time step, and eventually it intersects the plane. When this occurs, the velocity is reversed, but its position is also "snapped" to be above the plane so it doesn't appear intersecting. This small change in position without an accompanying decrease in velocity is what adds energy to the system and causes it to bounce back higher.
Ahhh that makes a lot of sense, thanks for clearing that one up for me :)
18:12
Break(GetEquilibriumForceMagnitude(Mathf.Deg2Rad * transform.rotation.x));
transform.rotation.x is the x element of the quaternion, why are you multiplying it by Deg2Rad?
What does this mean?
Deg2Rad is a constant (pi/180) and you multiply it by an angle in degrees to get the angle in radians. The function took in a radian value as an input so that’s why I did it.
I learned more from this video than I did in 9 weeks of college Physics (currently, as of writing this comment, we started going over momentum and impulse forces, but neither me nor any of my classmates understood anything in the class before this point, lol)
Glad I could help!!!
Correct me if I am wrong, but I think your saying of “the force that counters gravity” is a bit misleading... The definition of a normal vector is one that is perpendicular to a surface, which I think is fairly descriptive. On the other hand, what you are describing seems more like the positive y component of a force vector, which in general is not the same as a normal vector.
Other than that, this is a great video, and I’ll be following along to integrate physics into Unity. Thanks!
Edit: I noticed you misspelled “braking”, lol.
I totally agree that the actual definition of the normal force is more accurate, but I feel like a lot of complete beginners would start freaking out if I said something more technical like perpendicular to the surface. That is definitely a better definition if you know how vectors work, but with friction on a flat surface, referring to a normal force as the force that counters gravity is sufficient in my opinion. But yeah it is a little misleading when talking about normal forces and normal vectors in general, because they don’t necessarily have to be caused by gravity in the first place.
Thanks for watching and leaving the little correction!
Lol I am terrible at spelling so to only have 1 noticed spelling error isn’t too bad!
This was very good. You are a fantastic teacher also. Thanks for the effort.
Glad it was helpful!
This video is deadass just my AP Physics 1 class lol. Awesome vid!!!!!!!
I don’t know if it’s mentioned in the video as I haven’t finished it, but my favourite way to do physics only requires saving a velocity vector and simply multiplying that by a float that is in the order of `pow(0.99, MSPT)` every frame after velocities have been updated, as it will cap the velocity to a certain amount with a given acceleration. It also makes everything smooth and it’s really easy to change friction by changing the 0.99 into 0.999 for ice or 0.95 for more friction.
You can also change the friction based on direction of travel. For my game that I’m working on all accelerations work the same, it doesn’t matter if you’re on ice you know that if you start moving now and move 5 blocks right you’ll be at the same velocity as normal, having ice be slower acceleration is possible but I don't feel there's enough of a benefit.
The difference is when it comes to deceleration, changes happen when you either release controls or when changing direction (changing direction has higher drag allowing for quicker changes)
The movement feels amazing and fluid. Multiplying by a float less than 1 simulates air resistance without doing anything complicated and actually dealing with forces
That’s pretty big brain. To me it seems like a classic game dev solution of doing stuff that makes it feel like real life without being 100% accurate, and there is nothing wrong with that at all. This video was more designed as a physics primer and explain a bunch of physics concepts that would be useful to know when making games and how you can use them. So no, I did not cover any of that in the video, but good on you for finding a cheeky work around for all this silly real life math I’m doing lol!
This sounds like a Verlet integration?
38:20 you said you do not know why the dark green ball bounces higher the more it bounces. I THINK the reason why is the gravity will make the force at which it is moving down more so then it will bounce higher.
Idk if I understand you theory completely, but it sounds like you are saying that the force being exerted on the ball is higher when it is closer to the ground. I know that’s how our brains like to think of it because the ball is moving faster so there should be more force, but remember that force is related to acceleration and not velocity, so the force gravity exerts on the ball doesn’t change!
A bounciness of 1 should be a collision where no energy is lost, so if we do a bunch of math and cancel terms, we would get that, but computers don’t think like that. They just plug stuff into an equation and compute the answer which could lead to rounding errors if they used a velocity that wasn’t perfectly accurate. That’s my current theory, and something I would blame all of my slight inconsistencies whenever doing physics, rounding errors lol.
I have no definitive proof that this actually is the reason though…
@@WillHessGameDevI have thought more about this. I THINK that the reason for it bouncing higher is the force in applied for going down but only a fraction of that force is needed to hit the ground. then Unity makes it bounce at it's full power including the fraction that was not needed to make it hit the ground. which would explain why it only bounces a fraction more every time. but I could be wrong.
After a long day of chores, school, and boredom I wanted to learn some more c# and I saw this video, I already had a head ache this just 100Xed it
"Leaning tower of pizza" made me lol.
Superb video!
Thank you!
38:30
My guess as to why this happens would be that when unity detects the collision of the ball hitting the surface it bounces from, because the ball's position and velocity are updated discretely between frames, the ball's position and velocity can be updated to a point that places the ball inside the object and the collision is detected pushing the ball back up out of the object it would otherwise have entered, but the velocity is not recalculated. I.e. the ball now has as much velocity as it would have had had it continued falling a tiny distance extra into the surface of the object, but is positioned at the surface of said object. The bounce is then processed, flipping this higher velocity into the upward direction.
This can happen on every bounce, gradually increasing the energy of the ball.
Inaccuracies are caused by floating point error (so exact calculations are doomed to begin with) and time steps being discrete. Collision resolution behavior depends on the closing velocity of the colliding objects. I *think* at the bottom the system is more likely to lose energy because we are not using the real impact velocity but a velocity from 16 ms or so earlier. For the same reason we are always overshooting a little bit at the top, so if I am correct that is where energy is added to the system. We could relatively easy measure this for science - and it is possible that the system might get lossy instead if the variables are different - but it does not really matter since we should always be damping to make errors irrelevant. If we need a more stable system we could calculate the positions in absolutes instead of relatives (which does not really work for interactions) or see that we occasionally "correct" the values to a default or maybe have a constraint that keeps the energy consistent.
Decided to check this video out because im learning physics by myself and sometimes coding a primitive ball physics simulator. It was really helpful, thank you. Also you're cute. Subscribed.
No problem if you need any help just ask!
thanks a ton for this, it's very helpful for learning topics
Awesome Content 🔥 THANK YOU SO MUCH!
Thanks for watching!
Why at 2:40 are we taking 1/2 of the acceleration times time squared? Why is it only 0.5? Should it not be just 1 (e.g. no additional multiplication at all)
I thought the same thing when I started learning physics. It has to do with integration (calculus) which is the area between a graph and its axis. With a constant acceleration, the acceleration vs time graph (acceleration on y axis and time on x axis) will be a straight horizontal line because acceleration doesn’t change. Integrating acceleration gives you velocity so the area between the acceleration line and the x axis with the times as bounds is the area of a rectangle, length times width. Length is the final time, t (assuming you start at t = 0), and width is just the constant acceleration, so v = at. The graph of that is a linear function that passes through the origin with the slope equal to the constant acceleration. The integral of velocity is displacement (position) so we find the area between that line and the x axis, this is a triangle so the area is .5 * base * height. Our base is again t and our height is v which is at, so the area is .5 * at * t which means the position is .5at^2. It’s a bit confusing but I hope that made sense! If you have any other questions or need me to explain this better lmk!
@@WillHessGameDev oh, right! It took me time to wrap my head around your explanation but now it's clear, though pretty much counter-intuitive if you think about it without graphs
42:15 "zero equals one" and that huh sound with "?" symbol 😂😂 funny haha, and overall great video, thanks a lot for making it! ❤
No problem! Thanks for watching!
Great video. Slight presentation tip - your Ts look like + symbols, which can get confusing. Might want to draw them with the tail t.
I have the same problem with my r's and c's as I habitually curl my r a small bit at the bottom.
The worst for me are my 2s and Zs, they always end up looking identical lol. Thanks for the advice!
4:32 wouldn't the balls hit each other before they hit the ground, since because of the ball mass of 100 000 000 kg, it would accelerate the ball of 1kg, which is ~30cm away from the heavy ball (their centers), it would accelerate at 7cm per second per second, which would mean that if they fall for atleast 2.5 seconds, the distance between them would shrink to 0. Though it still doesnt change the point that they would hit the ground at the same time, so this is kinda useless.
I just used big numbers and small numbers to demonstrate the fact that the balls fall together. It was kinda a silly example and a dumb excuse to talk about the balls of a long dead scientist…
29:47 that's probably because of the shape, if you throw a sheet of steel and a sheet of paper they won't fall at the same speed because of the air AND the shape, but 2 balls will need a much greater distance to be able to see a diference
Either way if there is no air everything just falls at the same time
I stumbled onto this video yesterday as I've been researching game physics for a physics-light helicopter game I'm working on. The engine I'm using, Godot, does a terrible job of simulating drag, but I didn't fully understand how I would apply your approach (Fd=-bV) to Godot. Is -b just a "best guess" value?
I plan to do some experimentation and see what feels right, but my goal is to choose values and build a simulation that works with realistic properties applied to the helicopter assets I build AND to allow modders to add their own helicopters to the game without them having to do extensive math, just using a sane value for the mass, making sure the center of the node is the intended center of mass, and maaaybe having them calculate the center of pressure/drag and place a Node3D there.
Okay, this is getting long and I apologize, but I really want something that's realistic yet accessible for players and modders alike. Any guidance you may provide is appreciated. My experience with physics is basically just intuitive (playing KSP) and struggling to help my son with high school physics. lol
Yeah that -bv for drag isn’t the most accurate way of doing it, if you can and are trying to make things ultra realistic you’d probably want to use the more complex equation. It’s a bit more cumbersome and you’d need the cross sectional area to make it as accurate as possible.
The b can be calculated from your best guess at the objects terminal velocity.
Sorry it wasn’t a great answer but drag is very complicated to do 100% realistically
@@WillHessGameDev No, you're good. You could do another video much longer than this one just about calculating drag. I have a few ideas about how I might approach the problem by using a shader to get the reference area and working backwards from maximum airspeed to work out the drag coefficient. It's not a perfect solution, but once I have some numbers that are more or less working for me I can do some testing and at least make something that doesn't break the illusion for the player.
Thank you, BTW, for this video. Really helpful stuff.
As much as I love physics, a super long video just on drag would likely not perform well. I’m thinking about making more of a video series with all the main parts of this video as their own separate video, and showing implementations in unreal and godot as well, so for the drag video, I could go into a bit more detail. However it will not be anywhere near the length of this video lol. Thanks for watching!
@@WillHessGameDev that's a great idea. I hope it's well received. I certainly wasn't suggesting you should make a super long video on drag, lol. Just saying that's what it would take to discuss it in depth.
I'm no RUclipsr, but once I have a serviceable solution I might write something up on GitHub in hopes that it may help someone else.
At 16:12, I don't understand why that angle is 90 - theta and the adjacent angle is theta. And at 16:25, the normal force is equal to mg.cos(theta). Do you have any videos that can explain these concepts? (sorry for my english if u didn't understand.)
ruclips.net/video/ufgY237M5KQ/видео.html this guy is really good and he answers your question in the first 3 minutes of the video!
28:15 Is incorrect. The force of drag is not directly proportional to the velocity. It's directly proportional to the square of the velocity.
At 27:46 I talked about the drag equation, including velocity being squared. After that I talked about how the resistive force model dumbs everything down with the b and things not being physically accurate, just the key ideas of higher velocity = more drag. Unity uses the resistive force approach to drag which is why I showed that section the way it was
Amazing video! It really helped me understand physics better.
Thank you!
I have recommended it to my friends several times, but some of them struggle with it due to their limited knowledge of English (we are not native speakers).
Could you please let me know if I can create an AI translation and share it publicly (of course, with proper credit to you and without monetization)?
Yeah totally, again as long as you credit me that’s totally fine
Also thank you for asking before you did it! If you wouldn’t mind sending the link so I can pop it in the video’s description too to help other people too, that’d be great!
Hey can u also make a video on a ultimate guide on maths for game development centered around unity like u made in this one. It would really help
Definitely! With the success this video has gotten I’d totally be down to do that. I have my next few videos already planned out so maybe in a few months. Thanks for the idea!
I still remember how lost I was when learning this crap in Physics in Uni. Now it seems trivial, when applying it in practice.
Nice! Thank you for this!
No problem!
This guy wasn’t kidding. I tried using this tutorial with two others and now my furniture is stuck on my ceiling. Do not use any other guide.
Haha thanks for watching
I want to nitpick just the title and the premise. The video itself is pretty cool! well explained and edited. But this is not an ultimate guide for physics in videogames. This is a very superficial overview of basic physics and the Unity physics system.
Point taken, but I feel like it wouldn’t perform as well if I titled it “a very superficial overview of basic physics and the unity physics system”. Part of RUclips is to make clickable titles / thumbnails without click baiting, so my apologies if you thought it was more on the click baity side
Great video, subed ^^
Thank you!!!
hey do you have any insight into why most physics simulations - whether it's unreal, unity, blender, maya or houdini look FLOATY and slow motion when proper values are used for stuff like mass and gravity? like EVERY hard body collision demo - even your examples (sorry) - i swear it all looks slow and wrong and there's got to be some overarching reason why that is.....
In real life, nothing is actually a rigid body. A rigid body is just a convenient way to better understand what we want to understand. When things collide they squish and there’s this thing called the coefficient or restitution (I think (I am not an expert on this part)) that comes into play. This little bit of real life stuff makes the calculations needlessly complex. Also in the simulation everything happens instantly. What I mean by that is that if two objects collide, their momentums will instantly change, and in real life that is impossible (stuff just happens very quickly). That’s my best guess but idk if it is what’s actually going on.
@@WillHessGameDev i don't think those would result in the movement looking slower though. if anything, those factors would result in simulations looking FASTER. but in almost everything with real world values entered, simulations end up looking slow mo - in your example, the body getting hit by impulse doesn't fall as fast as a real world body would. in order to get a sack of potatoes to drop like a sack of potatoes in a sim, i have to jack up either the mass or the gravity to several orders of magnitude higher in order for it to look right. this has bugged me for as long as i've been doing cgi and i want answers! but thanks for fielding the question. the search continues.
@@jinchoung I think the falling thing is more down to perception. Even as Super Mario Bros on the NES used a higher "gravity" for the falling phase of a jump, to look and feel tighter.
There's no reason a free fall would actually be slower in a (decent) simulation, so long as sizes, distances and acceleration are consistent. What I mean is, if you put a ruler and a clock in your virtual world and measure the fall, it should match the real thing very well (so long as drag and stuff is minimal). So the difference is more perceptual, maybe because of how we translate images and sizes on images vs on the screen or something.
Also, in games we often want thing to go up way higher than they normally would, but we don't necessarily want them to take that much longer to fall, so there's all that I guess?
I don't know anything about game development except the physics. Just wanted to ask is fluid mechanics also needed for it?
Depends on what you are doing. Fluid mechanics aren’t something I know much about. I might be wrong about this but I think the concepts of fluid mechanics come from vector calc making everything a lot more complicated. If you are making a fluid simulation or something like that game where’s my water, then you’d probably have to know a bit of fluid mechanics but for creating stuff like oceans fluid mechanics is most likely not needed. It’s usually some sort of sine function offsetting vertices in a plane to create waves and then scrolling some normal maps, so not much real life physics. Sometimes making stuff look good enough is better than spending a long time getting things true to real life.
@@WillHessGameDev no, you are not wrong. Concepts of vector calculas are needed for Fluid kinetics and dynamics.
why do you add add 0.3 to the 0.74 value in the friction constant calculation in 24:07
At 22:47 I shows that the box has a static friction of .3 in the physics material, and the red surface has a static friction of .74 set to average. That means the .74 and .3 get averaged together to get the coefficient of friction in the actual friction calculation. So (.74 + .3) / 2 = .52
@@WillHessGameDev thanks
Probably mentioned in the comments, and maybe something you clarified somewhere deeper into the video, but acceleration is more correctly defined as a change in velocity and/or direction. So you could be traveling at constant velocity in a circle (constant angular velocity), but you are accelerating.
Yes that is 100% true, but I don’t think anything was incorrect about my definition. I believe I defined it as the change in velocity over the change in time. Velocity is a vector quantity so it has both direction and magnitude. I’m the case where the object is traveling in a straight line, direction stays constant and the magnitude changes, but in a circular path, an object traveling with a constant speed will accelerate towards the center of the circle. This is called centripetal acceleration and is a whole other topic I didn’t mention in the video, but the tldr of circular motion is that a=v^2/r. If I said acceleration was the change in speed over the change in time, then that would be wrong because it defies circular motion. I thought all of this stuff was too confusing to discuss in the video and make people click off because they were too confused, but yeah.
@@WillHessGameDev Apologies, you are correct.
Lol no need to apologize, you are also correct. The beauty of physics is that there are some things that are just needlessly confusing where we can be talking about the same thing and not even realize lol
"Threw his balls off the leaning tower of Pizza"
I don't know if you know how unbelieveably true this statement is
Lol
would you recommend any books because I want to learn more about these topics
I leaned physics from an ap physics class in high school. We used the serway jewett 9th edition I believe but I wouldn’t recommend that one just because of the sheer amount of other stuff in there. It’s really good but if you are just into the Newtonian mechanics (what this video was about) then getting that textbook is crazy overkill because it goes into electromagnetism, thermodynamics relativity and probably other parts of physics that I’m forgetting about. It’s also calculus based which if you understand the calculus involved then the concepts make much more intuitive sense but I could definitely see someone who isn’t well versed in calc getting very confused with some of the problems and explanations in that textbook. It’s really up to you but look for something with Newtonian / classical mechanics and with practice problems because doing problems is a great way to make sure you understand the concepts. Sorry I didn’t have a specific recommendation but I hope that helped!
good thing we were taught this in high school
how tf did you already do so many projects although you are so young 10/10
Thank you so much!!
very good but I wish you would have talked about verlet RK4 and Triangle collisions
Thanks for watching. I'm gonna be honest IDK what that stuff is so that's why it wasn't in the vid
Great job, appreciate it.
Thanks for watching!
Conceptually position is not a vector. It's a point. It just so happened that both vectors and points can be represented by tuples of numbers. In fact, each vector consists of two points: a starting point and an ending point. We just omit the starting point assuming it's in origin (0,0).
I might be wrong about this one but I’m pretty sure “displacement” is the vector, distance is the magnitude and position describes the point in space. I think…
@@WillHessGameDev yes, displacement is a difference between final and initial positions, so it's a vector.
now do one for graphics/lighting/rendering engine
Hahahaha I totally would if I understood anything about that stuff. Maybe some day but not soon
@@WillHessGameDev ill set a reminder. Really loved this video. also btw how old are you if you dont mind me asking?
Thanks! I’m 18 btw
You are awesome❗ Keep up the good work❗
Thank you ❗️
Well done. A great tutorial.
Thank you!
bro could've put a video of two objects hitting each other, but decided to risk his neck at 34:40
absolute chad
fuck me .. either I wasnt ready, or my teacher wasnt, way back when I was in school. Thanks for this easy to understand explainer.
No problem! Thanks for watching!
upthrust could also be something nice to add if you do anything like this again
Good to know!
I'd say this video is really good when you're using a game engine. But the title is a tiiny bit misleading (in my opinion), because I thought this would be more about physics (engines) from scratch and not just using something existing. But still for what it actually is, a good video!
Thanks for the feedback. I don’t really understand the point of making a physics engine from scratch if I’m being honest. There are so many amazing tools already out there, and unless you are a massive triple a studio, I don’t see why you would need to make your own. If it was the case where you are just curious about that stuff and you are just messing around, expecting a 1 hour RUclips video to clear it up is not very realistic. Thanks again for watching!
thanks brother this video is like a life saver
You're welcome! Thanks for watching!
Great video! Thanks a lot
Glad you liked it!
Although I liked the video just into it a few minutes, but you deserved a sub for the Galileo and his balls jokd 🤣🤣. I for sure know the video is gonna be great.
Thanks for subscribing!
I think the green box will continue sliding and the red one also will - LE
can you do more like this video math physics...
Yes. I have a few other videos I want to make first but I do want to do something similar and more comprehensive than this
Recommended this video to my friends.
Thank you!!!
Which book should I read ?
Sorry, What do you mean by that?
@@WillHessGameDev which book is good for physics for game developers
I don’t know if there are any physics books designed for game developers but the physics textbook I had was the serway Jewett 9th edition I believe. Its very good but again it’s just physics and has nothing to do with game dev. If the game engines physics system is accurate to the real world it will be very applicable otherwise not so much. Oh and the serway Jewett book also goes into electromagnetism which is not needed for game dev at all unless you are trying to accurately code in magnetic fields and stuff like that. So maybe consider finding another book solely on the mechanics of books are your thing.
Nice, remember to use a tick system to make all players on the same page (especially if you're making a multiplayer game, cause then exploiters will force the game to 1 FPS and get insane speeds!)
Idk if I explained it but it’s the FixedUpdate() function in unity
This video is amazing 🎉🎉🎉 thanks
I appreciate it!
The more math and physics you know, the more interesting games you can build. ex. Spore and Angry Birds. Unfortunately, those games don't expand for some odd reason.
Very true! In an upcoming video, I made a realistic grappling hook that doesn’t just arbitrarily add forces, but works realistically due to tension calculations! It was a pain to do but I could do it because I know math and physics!
@@WillHessGameDev I know calculus 2 and physics up to work.
I can definitely see that programming physics can be a pain, but it is doable.
My approach is to just let the engine handle it
If only i had this before taking ap physics
I mean I didn’t mention energy nor did I talk abt derivatives and integrals so idk how you’d do just with the video lol. Thanks tho!
38:13 floating point error
It’s the same reason that 0.1+0.2=0.30000000004. I used to have to deal with this all the time
To be more precise, what happens is the ball will go lower than the platform, then be snapped back up just a bit to correct for that floating point error, which adds a bit of energy. Specifically mgh, where m is the mass of the object, g is the local gravitational force, and h is the amount that got snapped back up.
What I usually do to fix this is either
a) ignore it
b) calculate the added gravitational potential energy and remove it from the kinetic energy
Ohhhh yeah I forgot about that one. Thanks for clarifying!
I love physique thanks a lot
Haha me too!