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.
@@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.
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
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”
lmao same, it was ostensibly "ap physics c" but we got a guy who only had chemistry training and ended up showing us grateful dead live videos instead. i got a 2 on the ap exam
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! :)
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!
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.
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.
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!
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.
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 🤦♂️
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.
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).
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 !
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.
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.
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…
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 ❤
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.
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.
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!
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 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)
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!
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.
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.
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
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!
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.
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.
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…
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!
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!
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)?
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!
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.
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
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 TH-cam video to clear it up is not very realistic. Thanks again for watching!
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
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 TH-cam is to make clickable titles / thumbnails without click baiting, so my apologies if you thought it was more on the click baity side
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 TH-camr, but once I have a serviceable solution I might write something up on GitHub in hopes that it may help someone else.
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!
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.
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.
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…
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!)
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
With your section on Friction, while what you said is entirely accurate, I would like to point out that constant friction, despite being the most accurate representation, will often feel unresponsive for the player or anything that would be alive, which is why I will typically add other "friction" constants that scale linearly and quadratically to your velocity to make it feel more responsive to the player controller and the movement systems for other "living" entities. And while your drag section is definitely interesting, it isn't actually that computationally expensive to represent the drag much more accurately, so, while it makes sense to represent it like that for most games, I typically will make my physics systems work off of -bv^2 for acceleration because it drives me crazy when I know that I implemented something innaccurately. Also, if you're implementing your own collision processing, it's actually a lot simpler than you would think, with varying elasticity essentially just being an interpolation between perfectly elastic, and completely inelastic collision. Completely inelastic collision can just be represented as taking the total momentum and dividing it by total mass to get the mass of both objects, and, though slightly more complicated, perfectly elastic collision can be simplified down to a few rules and isn't too hard to implement, even in 3 dimensions. And one thing which I think you should have mentioned would be the way in which rotational velocity is represented, because too many times I have seen friends directly modify the rotational velocity and get really weird results. So, for people interested in directly modifying rotation velocity, know that the direction of the vector represents the axis that it spins about, ie. a rotational velocity of would rotate about the x-axis, and the magnitude represents speed, so a rotational velocity would spin twice as fast. Importantly, however, this DOES NOT mean that a rotational velocity of would spin about the y-axis and x-axis simultaneously, instead, it would rotate between the two axes, which is how you can get weird gyroscopic procession when you mess with the rotational velocity vector directly. For those confused with how this works, I would personally recommend just interacting with whatever is equivalent to the AddTorque method in whatever physics engine you use.
By the way, if you have rotation, it doesn't actually make the collision system that much more complicated, and, for a temporary fix immediately after implementing rotation to your physics engine, you can just take the velocity deltas and use those to find the impulses, and then apply them locally so that you can process those in whatever function you have to process forces that aren't in-line with the center of mass. Keyword here for this method is "temporary," though, as this is not accurate, and can make inelastic collision seem more elastic than it is.
Wow that was very insightful! Thank you for leaving this. The thing with drag is that the -bv is how unity handles it and coding my own solution and explaining it in the video would definitely turn some people off so I decided to stick with how unity did 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.
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
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!
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.)
personally, I start by setting a few parameters, creating a dense ball of game objects, and allowing them to expand rapidly. Then I just wait a few billion years, and I get a free physics engine.
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.
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.
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”
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!
lmao same, it was ostensibly "ap physics c" but we got a guy who only had chemistry training and ended up showing us grateful dead live videos instead. i got a 2 on the ap exam
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!!!
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!
Finally a truly informational video. Instant sub.
Thank you so much!
Started looking into math and physics yesterday to buff my gamedev - will be checking this out, thanks for your effort boss!
No problem!
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!
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!
Great physics refresher video. Not sure what all the videogame stuff is about :D
Rock solid and practical, thank you for putting this out there for everyone!
No problem! Thanks for watching
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!
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.
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 :)
This kid is God sent to me …. Thanx buddy …. U r a genius …
It’s exactly what I needed… thanx
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!
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!
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 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.
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!
Now this is S tier content! Tnx so much! May your channel blow up!
Thanks!
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!
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!
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.
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!
Such a gem, hope you cover more physic topic in the future
Dude sounds like Michael Reeves if he hit puberty
Thanks… I think…
That's my friend is a golden standard of the gamedev content
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
thanks a ton for this, it's very helpful for learning topics
This video is deadass just my AP Physics 1 class lol. Awesome vid!!!!!!!
This was very good. You are a fantastic teacher also. Thanks for the effort.
Glad it was helpful!
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.
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 :)
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!
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
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!
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!!!
Awesome Content 🔥 THANK YOU SO MUCH!
Thanks for watching!
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!
"Leaning tower of pizza" made me lol.
Superb video!
Thank you!
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!
Nice! Thank you for this!
No problem!
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!
I still remember how lost I was when learning this crap in Physics in Uni. Now it seems trivial, when applying it in practice.
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!
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.
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
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!
i accualy want to develop games will this video be enough for the whole game physics sector? please reply.
Great job, appreciate it.
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!
good thing we were taught this in high school
Well done. A great tutorial.
Thank you!
thanks brother this video is like a life saver
You're welcome! Thanks for watching!
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.
Great video, subed ^^
Thank you!!!
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.
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?
You are awesome❗ Keep up the good work❗
Thank you ❗️
Great video! Thanks a lot
Glad you liked it!
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!
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!
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
how tf did you already do so many projects although you are so young 10/10
Thank you so much!!
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!
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 TH-cam video to clear it up is not very realistic. Thanks again for watching!
"Threw his balls off the leaning tower of Pizza"
I don't know if you know how unbelieveably true this statement is
Lol
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
Recommended this video to my friends.
Thank you!!!
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
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 TH-cam is to make clickable titles / thumbnails without click baiting, so my apologies if you thought it was more on the click baity side
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 TH-camr, but once I have a serviceable solution I might write something up on GitHub in hopes that it may help someone else.
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.
I think the green box will continue sliding and the red one also will - LE
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.
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!
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…
This video is amazing 🎉🎉🎉 thanks
I appreciate it!
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
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!
upthrust could also be something nice to add if you do anything like this again
Good to know!
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
bro could've put a video of two objects hitting each other, but decided to risk his neck at 34:40
absolute chad
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
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
I love physique thanks a lot
Haha me too!
My approach is to just let the engine handle it
With your section on Friction, while what you said is entirely accurate, I would like to point out that constant friction, despite being the most accurate representation, will often feel unresponsive for the player or anything that would be alive, which is why I will typically add other "friction" constants that scale linearly and quadratically to your velocity to make it feel more responsive to the player controller and the movement systems for other "living" entities.
And while your drag section is definitely interesting, it isn't actually that computationally expensive to represent the drag much more accurately, so, while it makes sense to represent it like that for most games, I typically will make my physics systems work off of -bv^2 for acceleration because it drives me crazy when I know that I implemented something innaccurately.
Also, if you're implementing your own collision processing, it's actually a lot simpler than you would think, with varying elasticity essentially just being an interpolation between perfectly elastic, and completely inelastic collision. Completely inelastic collision can just be represented as taking the total momentum and dividing it by total mass to get the mass of both objects, and, though slightly more complicated, perfectly elastic collision can be simplified down to a few rules and isn't too hard to implement, even in 3 dimensions.
And one thing which I think you should have mentioned would be the way in which rotational velocity is represented, because too many times I have seen friends directly modify the rotational velocity and get really weird results. So, for people interested in directly modifying rotation velocity, know that the direction of the vector represents the axis that it spins about, ie. a rotational velocity of would rotate about the x-axis, and the magnitude represents speed, so a rotational velocity would spin twice as fast. Importantly, however, this DOES NOT mean that a rotational velocity of would spin about the y-axis and x-axis simultaneously, instead, it would rotate between the two axes, which is how you can get weird gyroscopic procession when you mess with the rotational velocity vector directly. For those confused with how this works, I would personally recommend just interacting with whatever is equivalent to the AddTorque method in whatever physics engine you use.
By the way, if you have rotation, it doesn't actually make the collision system that much more complicated, and, for a temporary fix immediately after implementing rotation to your physics engine, you can just take the velocity deltas and use those to find the impulses, and then apply them locally so that you can process those in whatever function you have to process forces that aren't in-line with the center of mass. Keyword here for this method is "temporary," though, as this is not accurate, and can make inelastic collision seem more elastic than it is.
Wow that was very insightful! Thank you for leaving this. The thing with drag is that the -bv is how unity handles it and coding my own solution and explaining it in the video would definitely turn some people off so I decided to stick with how unity did it!
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
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!
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.)
th-cam.com/video/ufgY237M5KQ/w-d-xo.html this guy is really good and he answers your question in the first 3 minutes of the video!
personally, I start by setting a few parameters, creating a dense ball of game objects, and allowing them to expand rapidly. Then I just wait a few billion years, and I get a free physics engine.
That’s a pretty good idea, keep me posted in a few billion years to see how it turns out!
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.