Kinematic Equations (E03: ball problem)

Поделиться
HTML-код
  • Опубликовано: 17 дек 2024

Комментарии • 169

  • @VEGETADTX
    @VEGETADTX 5 лет назад +54

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

  • @Ebenchadnezzar
    @Ebenchadnezzar 6 месяцев назад +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!

  • @gamedevmania
    @gamedevmania 6 лет назад +78

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

  • @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.

  • @Zihan118
    @Zihan118 5 лет назад +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.

  • @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 3 года назад

      @@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

  • @davidjoelstevenson
    @davidjoelstevenson 2 года назад

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

  • @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!

  • @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

  • @uttkarshpratyush74
    @uttkarshpratyush74 Год назад

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

  • @victorkapustin629
    @victorkapustin629 5 лет назад +4

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

  • @thunderkilll1037
    @thunderkilll1037 2 года назад

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

  • @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)

  • @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

  • @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!

  • @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

  • @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.

  • @davegamedevelopment
    @davegamedevelopment 2 года назад +2

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

  • @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.

  • @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 ):

  • @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

  • @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

  • @angeldiaz7554
    @angeldiaz7554 2 месяца назад

    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!

  • @rubencrespo9699
    @rubencrespo9699 3 года назад

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

  • @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

  • @cuttlas2955
    @cuttlas2955 8 лет назад

    i love this Equations series

  • @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.

  • @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

  • @andre.drezus
    @andre.drezus 8 месяцев назад

    Saved me from a job challenge

  • @dominikseljan3043
    @dominikseljan3043 8 лет назад

    Wow, this was really awesome. Thanks Sebastian!

  • @AS-sb8uo
    @AS-sb8uo 8 лет назад

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

  • @RDD87z
    @RDD87z 7 месяцев назад

    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?

  • @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

  • @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

  • @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 ?

  • @sfgmonah
    @sfgmonah 6 лет назад

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

  • @x-lufias69
    @x-lufias69 2 месяца назад

    took me back to college days

  • @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.

  • @saurabhsharma5961
    @saurabhsharma5961 4 года назад

    GRRRRRREEAAATT HELP! Thanks a lot Sebastian

  • @browniboi2908
    @browniboi2908 3 года назад +1

    The 12 dislikes are from people who had a positive gravity

  • @alrightytighty1572
    @alrightytighty1572 4 года назад

    TYSM! This was a very useful tutorial.

  • @cuttlas2955
    @cuttlas2955 8 лет назад

    this was amazing please continue ....

  • @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;

  • @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%...

  • @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?

  • @shawarmagames1689
    @shawarmagames1689 11 месяцев назад

    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.

  • @xxxxx409
    @xxxxx409 2 года назад

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

  • @kipchickensout
    @kipchickensout 3 месяца назад

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

  • @asa989asa
    @asa989asa 2 года назад

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

  • @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

  • @Th3King86
    @Th3King86 2 года назад

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

  • @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 ?

  • @zainulabdeen1469
    @zainulabdeen1469 6 лет назад

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

  • @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.

  • @DAATChannel
    @DAATChannel 3 года назад

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

  • @Prasons
    @Prasons 7 лет назад

    Love you Seb!

  • @TristanPopken
    @TristanPopken 4 года назад

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

  • @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?

  • @hahoangmanh2086
    @hahoangmanh2086 8 лет назад +1

    really helpful. Thank you Sir

  • @int-64
    @int-64 5 лет назад

    Thank you Sebastian

  • @Eric-cu5oj
    @Eric-cu5oj 6 лет назад

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

  • @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.

  • @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.

  • @blacktopballer7385
    @blacktopballer7385 2 года назад

    is there a tutorial for this in gamemaker studio 2

  • @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?

  • @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.

  • @sreerajkc7978
    @sreerajkc7978 11 месяцев назад

    How to calculate g if h and t is given?

  • @alokkrishali4632
    @alokkrishali4632 4 года назад

    Great, awesome. Thank you very much

  • @oominrrzslydun907
    @oominrrzslydun907 3 года назад

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

  • @cakeu
    @cakeu 3 года назад

    This is amazing! Thank you so much!

  • @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

  • @Make0
    @Make0 4 года назад

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

  • @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?

  • @notwilko
    @notwilko 6 лет назад

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

  • @glitchover9894
    @glitchover9894 4 года назад

    how can i make that trajectory visible after build?

  • @microondas9966
    @microondas9966 3 года назад

    How would I change the speed of the ball?

  • @iKidBuu
    @iKidBuu 3 года назад

    is there a way to manipulate the speed with this?

  • @random_things_4_u
    @random_things_4_u 4 года назад

    Great tutorial.

  • @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

  • @kvskchaitanya4733
    @kvskchaitanya4733 4 года назад

    Can’t find link of the first episode.

  • @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.

  • @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

  • @gaerackjeong3697
    @gaerackjeong3697 8 лет назад

    Great tutorial thank you

  • @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 26 дней назад

      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

  • @noxabellus
    @noxabellus 7 лет назад

    How would you do this with point gravity?

    • @lorenzvo5284
      @lorenzvo5284 7 лет назад

      You really don't want to, believe me

  • @happymoments5016
    @happymoments5016 6 лет назад

    Thank you!

  • @haleemkehinde4546
    @haleemkehinde4546 Год назад

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

  • @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.

  • @Noss454
    @Noss454 2 года назад

    Thank youu. You are great ^^

  • @indidev2052
    @indidev2052 5 лет назад

    Hello thank you for this video but how can we achieve this same problem using character controller.

  • @MrMarkovicho
    @MrMarkovicho 4 года назад

    Assuming you want to add also a curved trajectory horizontally instead of letting the ball fly horizontally a straight line. How would that work ? anyone ? oO

  • @geri4367
    @geri4367 8 лет назад

    Great, great stuff

  • @nightfade2052
    @nightfade2052 3 года назад

    -18 m/s2 downwards is up

  • @Skyefaux
    @Skyefaux 6 лет назад

    Thank you!!

  • @ilhameffendi2737
    @ilhameffendi2737 7 лет назад

    my life saver :)

  • @bconnler
    @bconnler Год назад

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