Kinematic Equations (E03: ball problem)

Поділитися
Вставка
  • Опубліковано 28 лис 2024

КОМЕНТАРІ • 169

  • @VEGETADTX
    @VEGETADTX 5 років тому +54

    This is what I call a SIMPLE, CLEAR AND STRAIGHT TO THE POINT tutorial. Brilliant and crystal clear!

  • @gamedevmania
    @gamedevmania 6 років тому +78

    You deserve to be in one of those "People are awesome" sort of videos

  • @Ebenchadnezzar
    @Ebenchadnezzar 5 місяців тому +2

    Crazy how the exact problem I have been banging my head against the wall trying to solve for the past couple days was in a Sebastian video the whole time. Incredible stuff!

  • @TylerFerraro
    @TylerFerraro 8 років тому +19

    This is probably one of the coolest ways to visualize and learn the use of the kinematic equations while studying math in school. Love this series and looking forward to more.

  • @HadiExtreme
    @HadiExtreme 8 років тому +29

    Ah, finally! I tried to use this to create a bomb-like weapon that fires in an arc last month, but I couldn't get it working, even though I had Physics in high school and wasn't too bad at it. Damn, I forgot a lot of the essential equations. It's all coming back to me now. I even managed to solve the question at the beginning of the video before continuing.
    Also, the debug path thing is bound to be useful.
    Thanks for the video, Sebastian!

    • @mangomanlassi7779
      @mangomanlassi7779 3 роки тому

      im planning to do physics next year, is it worth it?

    • @jaylenli9310
      @jaylenli9310 2 роки тому

      @@mangomanlassi7779 I’m late, but I’d say physics is pretty useful in helping you understand a lot about things like kinematic equation as seen here but also to other things that will help you with realistic object collisions, etc

  • @KebeMaro
    @KebeMaro 7 років тому +1

    I'm addicted to game development videos now without people like you i'd be dead Thanks alot for doing these videos

  • @Zihan118
    @Zihan118 4 роки тому +6

    You know when it comes to hard stuffs, we always end up on your channel! We really love what you do Sebastian! Thanks for having us indie's back!

    • @CraftBasti
      @CraftBasti 4 роки тому

      May I ask what kind of game you're making?

    • @Zihan118
      @Zihan118 4 роки тому

      @@CraftBasti I made some peojectiles using this

    • @CraftBasti
      @CraftBasti 4 роки тому

      @@Zihan118 obviously, but what genre of game are we talking about? 3D RTS? 3D FPS? 2D Side Scroller?

    • @lurtztheorc
      @lurtztheorc 4 роки тому +1

      CraftBasti bump.

  • @davidjoelstevenson
    @davidjoelstevenson 2 роки тому

    Fantastic! I looked at several approaches that didn't work quite right before I found yours, and this calculation is PERFECT!

  • @angeldiaz7554
    @angeldiaz7554 Місяць тому

    Thank you so much for this, the AI couldn't just help me with creating an equation that would work, but this not only teach me a lot of stuff but helped me solve my problem, thanks a lot!

  • @adamlibby96
    @adamlibby96 6 років тому

    I adjusted your code to calculate where the ball will land if the target were moving at a constant speed. Thanks to you, I actually completed my project!

    • @awolr
      @awolr 6 років тому

      How did you do that? I'm having trouble with that issue

  • @mage443
    @mage443 4 роки тому +6

    Holy shit, I've been searching for this kind of thing for so much time now and it turns Sebastian had such an awesome tutorial for this, this whole time!

  • @uttkarshpratyush74
    @uttkarshpratyush74 Рік тому

    Solved the problem I was struggling with for like 5 days.. Thank you so much.

  • @thunderkilll1037
    @thunderkilll1037 2 роки тому

    Sebastian you saved someone's life today thanks man for the tutorial and alll the math you explained

  • @jnevercast
    @jnevercast 5 років тому

    This problem took me a couple years to solve for the Minecraft Mod: OpenBlocks's Canon. Thanks for a nice explaination - years later ;D

  • @victorkapustin629
    @victorkapustin629 5 років тому +4

    You'r a genius, man! Fantastic, finally I found exactly what is needed!! Thank you!

  • @MrKingJavo
    @MrKingJavo 8 років тому +1

    Thanks for doing this tutorial. It would be cool to see how it works with a moving object. I think I can figure it out given this foundation, but you are the king and your tutorial would probably show me things I'm missing. Good job!

    • @MrKingJavo
      @MrKingJavo 8 років тому

      *Meant moving target, not object.

    • @MrKingJavo
      @MrKingJavo 8 років тому

      Just a heads up... if you set the Gravity to -60 ish, then the ball misses the target. Any idea why?
      rigidbody.velocity assign attempt for 'Ball' is not valid. Input velocity is { NaN, NaN, NaN }.
      UnityEngine.Rigidbody:set_velocity(Vector3)

  • @unscriptedlogicgames
    @unscriptedlogicgames 3 роки тому +5

    Will you continue this series? I would like to see more and learn more in your way of teaching. It's really helpful

  • @nawakman
    @nawakman 3 роки тому

    it is 1am and I finally understood, thank you for the video you make it easy to understand

  • @callmedeno
    @callmedeno 7 років тому

    omg i was going to suggest this as a video i thought would really suit your channel and I happened to be having some problems with it, just happened to glance through your videos and BOOM, thanks!

  • @davegamedevelopment
    @davegamedevelopment 2 роки тому +2

    Thanks, I feel like Isaac Newton now. Super satisfying to see the ball always hit the hoop perfectly :D

  • @zimi992
    @zimi992 5 років тому +3

    Hi, You and Your solution are awesome ;) There is one small improvement that can be made, at least to Your code on github. I would call Mathf.Abs() on every math inside MAthf.Sqrt() and than it can also work if target is lower than ball :) Thanks again for this great video.

    • @branthegame6208
      @branthegame6208 5 років тому +1

      hey man , could you please do your change to code. obviously there is an issue with current one.whenever i move the target object and the curve is about to become a straight line the curve will be disappear and everything mess up ):

  • @VladimirEmelyanov
    @VladimirEmelyanov 4 роки тому

    You are amazing! Your videos solve so many my problems during game developer work... i so love you! THANK YOU SO MUCH! I really try boost up my mathematics skills but some tasks is really difficult.... you are great...

  • @siddharthtrivedi3322
    @siddharthtrivedi3322 2 роки тому

    Amazing explanation sir :)
    Thank you for making whole process simple.

  • @diliupg
    @diliupg 5 років тому +2

    Thanks very much! Changed the code and using it for a 2D game. WIll use for a 3D game in the future. Many merits.

  • @VoidAshen
    @VoidAshen 4 роки тому +1

    Vector3 DisplacementZ = new Vector3(0f, 0f, Target.transform.position.z - Ball.transform.position.z);
    Vector3 velocityZ = DisplacementZ/ (Mathf.Sqrt(-2 * height / Gravity) + Mathf.Sqrt(2 * (DisplacementY - height) / Gravity));
    add these 2 lines of code and works in 3d, i mean when u move the object left and right

    • @ssojyeti2
      @ssojyeti2 4 роки тому +1

      don't forget to change displacementXZ to displacementX and then set its Z coordinate to 0. then your code works great :D

  • @steventhecat
    @steventhecat 8 років тому +12

    How would you go about using these equations to calculate the impact point of a thrown object? Every example I've seen predetermines the final position, but I want to know the landing point, given the initial velocity.

    • @TheBetito123
      @TheBetito123 7 років тому +3

      Steven then x=initv*time-0.5gt^2

  • @MannyTheSaxCat
    @MannyTheSaxCat 4 роки тому

    Math is magic!! thanks for this. I'm using it for a baseball game with players throwing the ball back and forth

  • @rubencrespo9699
    @rubencrespo9699 3 роки тому

    Thanks for this fantastic lesson, very useful for my game.

  • @cuttlas2955
    @cuttlas2955 8 років тому

    i love this Equations series

  • @fastsolution
    @fastsolution 6 років тому +2

    i know we cannot control the speed of ball but is there any work around ? i am making football shoot game

  • @dominikseljan3043
    @dominikseljan3043 8 років тому

    Wow, this was really awesome. Thanks Sebastian!

  • @shawarmagames1689
    @shawarmagames1689 10 місяців тому

    Lovely tutorial. Except you didn't had to drive a formula for initial velocity for horizontal. You can directly use V = d/t and that's what your derivation ends up at.

  • @andre.drezus
    @andre.drezus 7 місяців тому

    Saved me from a job challenge

  • @browniboi2908
    @browniboi2908 3 роки тому +1

    The 12 dislikes are from people who had a positive gravity

  • @sandplanet471
    @sandplanet471 2 роки тому

    due thank you so much for making this. i was tryna implement somethig like this into my recroom game and i was having a brain aneurysm tring to put the equations in. Instant Like and sub

  • @darryljf7215
    @darryljf7215 4 роки тому +3

    Great video, I played around with it a bit. If I assume the ball is a soccer ball and add a reasonable drag coefficient(Cd) on the ball, say 0.25 - then the ball stops about half way. Is it possible to modify these equations to take into account the Cd ?
    Does anybody know how I might be able to do this ?
    (edit) The equations Sebastian provides is for 'high school' physics. When you add a drag coefficient onto your ball then the formulas don't work anymore. This is bc of air resistance (drag). There is an eq for air resistance but it is not a one time formula, you need to keep applying it per frame. Hence you cannot predict exactly where the ball will land. You can use integrals to get a fairly accurate path but in Unity it is not 100% accurate.

  • @neozoid7009
    @neozoid7009 2 роки тому

    Super Awesome tutorial thanks Sebastian . But Why this not works if target position is too high ?? How to solve this ??

  • @ahmadahsan6721
    @ahmadahsan6721 3 роки тому

    Great work, very helpful. Thank you

  • @x-lufias69
    @x-lufias69 2 місяці тому

    took me back to college days

  • @sfgmonah
    @sfgmonah 6 років тому

    Thanks a lot man !
    That helped me a lot in my Unreal project !

  • @RDD87z
    @RDD87z 6 місяців тому

    i think i saw one video where you show some of the games you made through the years, and there was a game i would like to know how to make it, its like a mouse cursor dodger, where you need to try click a moving target on the screen, the target will move around and away from your mouse cursor on a precise way, dodging your cursors velocity maybe...? it didnt look like randomly moving cause that would obviously make the dodger fail by walking into your cursor x y position...
    i didnt find it again, can you tell me about it?

  • @kipchickensout
    @kipchickensout 3 місяці тому

    i searched for something along the title, click, "hi everyone" IT'S HIM

  • @AS-sb8uo
    @AS-sb8uo 7 років тому

    All I can say is , its time to subscribe ..superb

  • @xxxxx409
    @xxxxx409 2 роки тому

    Thank you, but is there any reason that checking debug is not showing draw path? Everything else works perfect good work !!!

  • @saurabhsharma5961
    @saurabhsharma5961 4 роки тому

    GRRRRRREEAAATT HELP! Thanks a lot Sebastian

  • @Th3King86
    @Th3King86 2 роки тому

    Is it possible to change the speed of the moving projectile without causing it to leave it's arc?

  • @int-64
    @int-64 5 років тому

    Thank you Sebastian

  • @cuttlas2955
    @cuttlas2955 8 років тому

    this was amazing please continue ....

  • @alrightytighty1572
    @alrightytighty1572 4 роки тому

    TYSM! This was a very useful tutorial.

  • @speedpower2951
    @speedpower2951 2 роки тому

    Physics.gravity affects all objects in the scene. Is there a esy to do this affecting the gravity of this single object?

  • @TheFingledorf
    @TheFingledorf Рік тому +1

    If the ball is missing the center of the hoop by 0.5 to 1 unit, this *might* help: I haven't watched the full video, but I asked about this for the first video (Mario jumping) on the Unity forum, and while I didn't understand the full explanation, apparently it has to do with Unity using semi-Euler approach to physics and not calculating the velocity based on the first physics frame but the second instead (or something like that). Try adding "... + (0.5 * Time.fixedDeltaTime * (whatever your acceleration is, the gravity) * -1) * Vector(dot)one" to the initial Rigidbody2D velocity and see if that helps.

    • @KnightWhoSaysNi
      @KnightWhoSaysNi 8 днів тому

      Where did you get this formula from? I can't get the ball to hit the center with either Sebastian's original code or your addition

  • @nikolazugic1300
    @nikolazugic1300 8 років тому

    This is the most thorough explanation of the subject I've seen so far. One question regarding the for loop when drawing the line: Is it a valid way for an AI to check if he can jump on a point (and not hitting the ceiling e.g.) or is there another way of doing it?

    • @SebastianLague
      @SebastianLague  8 років тому +1

      It is a good way, although obviously you can use a much lower resolution.

    • @programmer1up286
      @programmer1up286 8 років тому

      Hi Sebastian , I'm making a space exploration game in unity and the planet terrain has been stumping me for a while now and I was wondering if you could possibly help me at all or make a procedural planet series?

  • @asa989asa
    @asa989asa 2 роки тому

    Dude, you are fu*king awesome. Thanks a lot.

  • @day_that_i_die9854
    @day_that_i_die9854 2 роки тому +1

    How can I make flying object (let's say a missile) to look in the same direction as tangent to parabola ?

  • @Make0
    @Make0 4 роки тому

    Why did you choose equation 4 for solving t? Wouldn't any of 1-3 work also?

  • @Ranner198
    @Ranner198 8 років тому +6

    I have a question, why did you use 18m/p^2 instead of 9.81m/s^2?

    • @SebastianLague
      @SebastianLague  8 років тому +5

      I prefer the solution + given information to all be integers for example problems.

    • @Ranner198
      @Ranner198 8 років тому

      I got you, my ocd was like hold up! XD Nice Video Btw!

    • @Denisowator
      @Denisowator 8 років тому

      +Ran Crump *ocpd

    • @TheRusear
      @TheRusear 8 років тому +2

      Probably because he wants to put that value. As a programmer you can make your own Physics engine and that includes switching the real values for values you want. If you write the code in the video and change the gravity default value for -9.81 you will have a good result using real values.

  • @tomh9206
    @tomh9206 2 роки тому +1

    For those want to change the velocity to get to the target, you can simply increase the gravity apply to the launch object.
    I am using this method in my 2D project and I don't want to change the whole Physics2D setting. So I make Rigidbody2D.gravityScale = gravity(in this video) / Physics2D.gravity.y;

  • @microondas9966
    @microondas9966 3 роки тому

    How would I change the speed of the ball?

  • @AnthonyFassolas
    @AnthonyFassolas 6 років тому

    Looking to create a script where a game object moves in a parabola from point A to point B , unlike this video where physics works, I just need it the game object to travel between those points, any help on that ?

  • @bronzemoongames
    @bronzemoongames 3 роки тому

    Old but very nice tutorial, however, I can't figure out why you have taken the gravity as -18 m/s2 instead of -9,81 m/s2 as it is supposed to be. This deviated the simulation 1.4 times off of the reality.

  • @pestantium
    @pestantium 8 років тому +2

    It should also take into account the mass of the object. And do not start from the value of 1.

    • @SebastianLague
      @SebastianLague  8 років тому +8

      What difference do you expect the mass of the object to make?

    • @pestantium
      @pestantium 8 років тому +7

      I'm sorry. All formulas are mass independent - Trow ball by velocity, not by AddForce or else. My mistake. I checked your example on my project.

  • @alokkrishali4632
    @alokkrishali4632 4 роки тому

    Great, awesome. Thank you very much

  • @Prasons
    @Prasons 7 років тому

    Love you Seb!

  • @muratkul7377
    @muratkul7377 4 роки тому

    Great tutorial.

  • @blacktopballer7385
    @blacktopballer7385 2 роки тому

    is there a tutorial for this in gamemaker studio 2

  • @DAATChannel
    @DAATChannel 3 роки тому

    Now I can create a shooting mechanic for my basketball game!

  • @Eric-cu5oj
    @Eric-cu5oj 6 років тому

    AWESOME, MAN!!! THANKS A LOT!!! Thats what i need!

  • @hahoangmanh2086
    @hahoangmanh2086 8 років тому +1

    really helpful. Thank you Sir

  • @cakeu
    @cakeu 3 роки тому

    This is amazing! Thank you so much!

  • @oominrrzslydun907
    @oominrrzslydun907 3 роки тому

    i think (velocityXZ + velocityY * -Mathf.Sign(gravity)) is equal with velocityXZ + velocityY. why need to times -Mathf.Sign(gravity) ?

  • @TristanPopken
    @TristanPopken 4 роки тому

    Ive got a question, is it possible to calculate this if you know the horizontal motion and not the highest point?

  • @happymoments5016
    @happymoments5016 6 років тому

    Thank you!

  • @zainulabdeen1469
    @zainulabdeen1469 6 років тому

    if we consider some drag force in forward dierction than what will be the changes

  • @glitchover9894
    @glitchover9894 4 роки тому

    how can i make that trajectory visible after build?

  • @edusilveira777
    @edusilveira777 6 років тому

    Does anyone know how I would be able to implement a projectile-motion-like approach to this ? I have a very similar situation, but with a cannon, so the cannon's rotation needs to influence both the x and y velocities. I have already tried implementing the cos(angle) for the x speed and sin(angle) for the y speed, but it didn't work 100%...

  • @fabianschafer9311
    @fabianschafer9311 3 роки тому

    Maybe someone solved this problem already but I cannot stick my head around it. I copied the code exactly as written in this tutorial but the center of my ball seems to miss the center of the target by about 0.5 on the x-axis. The calculated velocity is the same and I positioned all my gameobjects as in this scene... Anyone having an idea about this weird behaviour? I tried to watch this video in slow motion but I just cannot see wether the ball trajectory would hit the targets center given the colliders would be inactive.

  • @iKidBuu
    @iKidBuu 3 роки тому

    is there a way to manipulate the speed with this?

  • @jessemauritz1
    @jessemauritz1 4 роки тому

    so question. I wanted to get this equation to work in a unity project, but I am wanting to use it with a grenade, so I place an empty object in front of the player, and that is the endpoint and the player is the start point. I can not figure out how to convert it tho, any ideas?

  • @TheRiddl37
    @TheRiddl37 4 роки тому

    Great video Sebastian, but what if you don't have the max height constraint and you still want to shoot an arrow in a curve between two points.

    • @CumuloWinter
      @CumuloWinter 3 роки тому

      I think you'd need to pick a height, since an arrow can be shot in a curve between two points in a number of different angles, even in a straight line. If it were three points then you could use the middle one as the height

  • @notwilko
    @notwilko 6 років тому

    Could you do a tutorial on leading a target? Like for a sports game...

  • @kvskchaitanya4733
    @kvskchaitanya4733 4 роки тому

    Can’t find link of the first episode.

  • @mgnovennohappy
    @mgnovennohappy 3 роки тому

    how to calculate the wind (x-only), for this formula: VelocityX = DisplacementX / (Mathf.Sqrt (-2 * h / gravity.y) + Mathf.Sqrt (2 * (DisplacementY-h) /gravity.y)); ?
    Who knows?

  • @sreerajkc7978
    @sreerajkc7978 11 місяців тому

    How to calculate g if h and t is given?

  • @emielvanessen5896
    @emielvanessen5896 8 років тому

    Hey Sebastian, awesome tutorial, I've been tinkering with this problem for a while now, you really helped me out, but I've one question, could you explain how I could apply this to a moving target?

    • @killereks
      @killereks 6 років тому +1

      Emiel van Essen i have a video on my channel on a turret that hits moving target 100% of the time

    • @killereks
      @killereks 6 років тому +1

      Also works in 3D

  • @Noss454
    @Noss454 2 роки тому

    Thank youu. You are great ^^

  • @gaerackjeong3697
    @gaerackjeong3697 8 років тому

    Great tutorial thank you

  • @nightfade2052
    @nightfade2052 3 роки тому

    -18 m/s2 downwards is up

  • @bconnler
    @bconnler Рік тому

    my god... copy paste... i love you

  • @geri4367
    @geri4367 8 років тому

    Great, great stuff

  • @kartakartak
    @kartakartak 8 років тому +2

    Hey,
    I'm not sure if this is in the video but...
    Is it possible to adjust the speed of the ball?
    kind regards

    • @EntropicalNature
      @EntropicalNature 7 років тому

      I'm not sure whether you understood the purpose of this video. The ball's speed is actually being calculated in script so it always hits the target. Setting/adjusting the speed of the ball is easy.

    • @fastsolution
      @fastsolution 6 років тому

      i have the same question is there any work around ?

    • @fastsolution
      @fastsolution 6 років тому

      how can i increase the speed?

    • @maxokaan
      @maxokaan 6 років тому

      Hi, I found a solution to some extent. You can decrease the gravity value to -40 for a quick ball and increase it to -5 for a really slow ball. This is not the best solution, but it works as long as you don't change the values too much.

    • @fastsolution
      @fastsolution 6 років тому

      first i did it with timescale when launching ball .second s0lution is to increase the velocity on z axis but it will cause accuracy problem

  • @ty-xq7bl
    @ty-xq7bl 2 роки тому

    ty sooooooooooooooooooooooo much

  • @쿡스-q9w
    @쿡스-q9w 4 роки тому

    really thank

  • @TheTempini
    @TheTempini 5 років тому

    I know this is an old video but how would you dynamically change the height of the arc based on the distance you are throwing it rather than have it as a set value?

    • @lesetrife
      @lesetrife 5 років тому

      I think you have to fix velocity or other parts to do that... In this case he fixed height.

  • @Sujisan4
    @Sujisan4 8 років тому +1

    Question, are you done with the procedural terrain series?

    • @SebastianLague
      @SebastianLague  8 років тому +5

      +Sujisan4 I am not. I had planned to release the next episode end of nov, but looks like it will be early dec instead.

  • @Skyefaux
    @Skyefaux 6 років тому

    Thank you!!

  • @HieuTrung-on5wr
    @HieuTrung-on5wr 5 років тому

    Wow, amazing, thạnk you !

  • @infinityscoregames
    @infinityscoregames 7 років тому

    Helpful video. But i have a question:
    How can i decrease the time?

    • @TheBelrick
      @TheBelrick 4 роки тому

      The rate of fall is a constant irregardless of the forward velocity of the ball. So to get the ball to hit a fixed target simply make the arc shallower. e.g if target is at 9, make the highest point of the arc, H, 9.0001

  • @adamzbierski1913
    @adamzbierski1913 5 років тому

    mate could i change the speed the ball is travelling at ?

    • @jnevercast
      @jnevercast 5 років тому

      If you increase the gravity, the speed will be faster to compensate. If you decrease H (peak height) then the ball will be more direct and will have to go faster to counter gravity. But outside these constraints, going faster just means you miss the target in a purely physical simulation.
      One option is that instead of a Rigid body you could use this math to create an animation and you can play that animation at any speed you like.

  • @ilhameffendi2737
    @ilhameffendi2737 7 років тому

    my life saver :)

  • @haleemkehinde4546
    @haleemkehinde4546 11 місяців тому

    Got so lost at the lets draw a line part 😂😢