Introduction to Game Development (E22: trigonometry)

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

КОМЕНТАРІ • 126

  • @Steven_Something20
    @Steven_Something20 7 років тому +166

    A 15 minute from Sebastian > a full semester of trig 270. Although this was 9 years too late for me, I know it will help someone else out there. Thanks for the upload as always!

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

      Exactly my thoughts. Awesome.

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

      Shouldn't theta be 60 degrees for the first problem when using sin for the angle within the 90 degrees triangle ? the 120 degrees you're using for theta is outside of the internal angle for the right angled triangle.

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

      Dave Dogge I think so.

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

      definitely helped 8th grade me.

  • @benj4432
    @benj4432 7 років тому +111

    This has to be the most well-made and well-thought-out tutorial I`ve ever seen. I learned more from this 15 minute video, then 3 hours of work in school. And for that I thank you.

    • @PrototypeTheta
      @PrototypeTheta 7 років тому +23

      In all seriousness game dev is one of the easiest ways to learn complex maths. It's much easier to pick it up when you have an actual reason to use it.

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

      Prototype Theta Yeah, it's really amazing. I wish it was possible to have lectures like this in school, would help me concentrate so much more. And the visuals really aid the understanding!

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

      Prototype Theta, I agree with you.

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

    You have no idea how painfull this was to me, ahving the objects rotated in the wrong way and me just adding angles to make it face the right way and being frustrated by it. Now I know why and how it all actually works. Why everybody who makes "tutorials" on rotating your characters just say, oh here, copy pasta this code don't worry about it, when the explanation is so simple! Zero starts at X axis and goes anti cloack wise. SO SIMPLE!!! YET NOBODY EXPLAINS IT!!! I'm sooooooooooooo mad that the answer was so simple and yet I learn about it just now.
    Sebastian is the real unity MVP!!!

  • @razakhan651
    @razakhan651 4 роки тому +36

    How to remember Sine cosine and tangent:
    SOH CAH TOA
    SOH: Sine is opposite over hypotenuse
    CAH: cosine is adjacent over hypotenuse
    TOA: tangent is opposite over adjacent

    • @bobdagamer640
      @bobdagamer640 2 роки тому +4

      We got taught it as Silly Old Hitler Coudnt Advance His Troops Over America

    • @Maggiethegsd
      @Maggiethegsd 2 роки тому +3

      @@bobdagamer640 💀

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

      In France we say CAH SOH TOA (casse-toi = get the hell out)

  • @_-__-_6355
    @_-__-_6355 7 років тому +13

    The production on these videos is off the charts. Amazing!

  • @lando6583
    @lando6583 2 місяці тому

    thank you for this! Finally someone succinctly explained why we use Atan2!!!

  • @MG-mm7mn
    @MG-mm7mn 2 роки тому

    I don't need to watch a Sebastian's video till the end to give a Like. Before watching I've already given.

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

    my my, the best explanation i ever had about trigonometry

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

    Thank you so much for this video. I just completed a computer science degree and I did not know before what is the meaning of a radian. Now I can understand what I have done so far.

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

    I literally don't understand how anyone could dislike these on purpose.

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

    A little late to the party, but wanted to point out something that I didn't see in the comments and I don't believe was mentioned in the video: there's a difference between the two ways of implementing the rotation ("90 - " method and swapping x and z).
    If you use the "90 - " method (the first one you showed), whenever we give no input, Atan2 is going to become zero (as it should, since the inputDir will just be a Vector3 filled with zeros). However, because we have that constant 90 degrees subtracting from Atan2 * Rad2Deg, the input angle becomes 90 degrees. This means that when we are not pressing anything, our character will face sideways, rotated about the y-axis by 90 degrees.
    This doesn't happen when we swap the z and x in the Atan2 function because the constant 90 degrees is not there anymore. In this case, when Atan2 goes to zero (whenever we give no input), the entire inputAngle variable becomes zero, as it should, meaning our character will face forward (+Z) with no input instead of sideways (+X) as it did in the "90 - " method.
    I think this explanation is right? Please correct me if I'm wrong.

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

      yeah it worked for me, for some reason the player wouldn't rotate diagonally but this fixed it!

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

    This video video series is simply amazing, but this video in particular should help everyone understand what's going on in the movements. I was getting really confused about that because there are so many different ways of doing it, not to mention the rotation added on top. Thank you thank you thank you. And now I know trigonometry too ... I feel like I should go take a university trig course and get credit for it !!

  • @emad-dev
    @emad-dev 7 років тому +4

    FANTASTIC TUTORIAL, please make more like this.

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

    this guy is AWESOME math teacher ! i wish i had a teacher like u in the school.

  • @Niklas-cd3sb
    @Niklas-cd3sb 5 років тому

    Thanks for this great video. These 15 minutes explained a lot although c# programming, cos, sin and atan are new territories for me. Now i understand most of it and have a solution to my problems. Keep the work up

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

    The explanation makes these so easy to understand, thank you!

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

    I swear it's like i asked you to do this just in time :) , Today i posted a question on unity form about this and now u uploaded, i think i'm able to do it on my own but i'll surely understand what im doing better after i watch this so thank you

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

      Nadim78Nadim NFA SAME HERE, BRO

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

    me watching other trig videos: *visible confusion*
    me watching this trig video: *visible happiness*

  • @powersupersport
    @powersupersport 7 років тому +23

    I want you as my teacher in college!

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

    Great video! I really like how you teach difficult things in a simple way.

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

    Damn amazing! This bloody thing in just 15 minutes but so well explained. Thank you so much!

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

    Half a year ago, when I first met Unity, I succesfully "implemented" the Quaternion.LookAtRotation & Quaternion.Slerp functionalities. Just when I finished, I saw in a tutorial, that what I wrote in ~60 lines in days, there are these functions prewritten for you:D Good times.

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

    Fantastic video! Keep up the great work.

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

    Thanks a lot for this tutorial :) You are a amazing teacher !

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

    best trigonometric explanation ever. :)

  • @PrototypeTheta
    @PrototypeTheta 7 років тому +31

    Any chance of a video explaining rotation matrices/quaternions?

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

      I think he said he´ll be making a video on Quaternions soon.

    • @JoeMakaFloe
      @JoeMakaFloe 4 роки тому +19

      @@novacti5254 *so that was a fucking lie*

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

      Check the chanel of 3blue1brown, he has awesome videos explaining math stuff

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

      @@novacti5254 its been 5 years

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

      @@pitchblack5422 The dream lives on :')

  • @vpsop2745
    @vpsop2745 4 роки тому +22

    Petition to make him college teacher. He explains better

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

    perfect timing, i need to rotare sprites to face their moving direction and this will solve all my issues

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

    Nice info tutorial, Sebastian, well done! I would just like to point something out, this angle conversion is not necessary(?) when we are working in 2D once the positive z-axis (which is the main axis for rotation in 2D) is pointing "opposite to the user". This can be seen when as we increase the rotation in the z-axis, the gameObject will rotate anti clockwise instead of clockwise (without any conversion)

  • @YassirAitichou
    @YassirAitichou 3 місяці тому +1

    thank teacher for this video

  • @clodgozon3968
    @clodgozon3968 5 років тому +10

    Damn, this is understandable even for 8th-graders like me!

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

    You are a fantastic teacher!

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

    And here I thought I would never use Trigonometry after I graduate.... 13 years later, I'm brushing up on Trig for my game development career. I've come full four quadrants.

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

    Crystal clear. Appreciated.

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

    almost after 5 years of being professional game developer still watching this video for rotating god damn cube 😅

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

    Ha! After all my struggles with figuring out everything on my own. I learn a lot, on the way and how trig can be used. Oh well, I guess its not too bad learning this anyway.

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

    I am wondering if you meant to keep 120 degrees as your reference angle? As I am on the toilet I cant check whether you actually used 60 degrees for your calculation and just forgot to update the graphic. I'm taking pre calculus and was wandering what real use trig has within programming. Now I know, very interesting video none the less, thanks for the time and effort. Cheers.

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

      I can't see why he used an angle which is external to the right angled triangle, I think you're right, he should have used 60 degrees for the theta angle in the first example. 120 degrees has nothing to do with calculating the cos, sin or tan of that triangle.

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

    Great work again, I wish you all the best for the future. I am aware you have had some contact with the good people at Unity, so maybe you know the reason why they didn't use the mathematical convention on this (and the standard forward direction for that matter). If you do, I'd love to know.
    That mini project looks cool, I might actually re-download Unity and review my C# to do it.

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

    Thank you for making this.

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

    Are the tooltips about all the methods and parameters you use a monodevelop feature? How can I get those to show up in visual studio? It would help me learn so much 😅

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

    I have an advantge of asking my mom about maths since she is very smart at it🥳🥳

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

    Shouldn't theta be 60 degrees for the first problem when using sin for the angle within the 90 degrees triangle ? the 120 degrees you're using for theta is outside of the internal angle for the right angled triangle.

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

      I know I'm super late to the party, but with trig, the triangle is for visualization. you care about the vector of r=1. so you take the angle from origin not in the triangle.

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

    Can someone explain why it is used transform.Translate relative to the World space, I used relative to local space, and bugs on the movement have appeared.
    Awesome tutorial btw, well done Sebastian!

  • @Salvadorioo
    @Salvadorioo 7 місяців тому

    I feel, it will be very interesting day☺

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

    "B-but when am I ever gonna use this in real life?"

  • @段然-e1d
    @段然-e1d 7 років тому +1

    during about 9:20, you use Vector3 direction = new Vector3(Mathf.Cos(angleInDegress * Mathf.Deg2Rad), 0, Mathf.Sin(angleInDegress * Mathf.Deg2Rad)). I don't know why you use the Cos and Sin here, Can you please explain? thanks!
    为什么这里的Vector3的x一定是Cos呢,为什么不能是Sin?

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

      He is trying to find the direction his character should be facing based on the angle that is used. As he explained earlier in the video, you find the direction by taking the Sin and Cos of the angle, multiplied by the degree-to-radian conversion, and place that into your coordinates (x, y).
      (I know I'm answering this question 8 months after it was asked, but maybe someone will stumble upon this video later and have a similar question)

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

    Sebastian could you make tutorial how to move empty object,with some velocity, along the circle with equations (cos(theta),sin(theta)) ?

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

    Ok so you never know, I'm posting here and hope someone reads this and can help me : I have litterally copied this code into my script. Everything behaves as it should except for one thing : when I dont have any key pressed, the rotation resets to zero. So when my "character" stops moving, it faces 0°, instead of facing the direction of its last movement. Can anyone help ?
    Besides, I love your series, this is a huge help ! Thank you.

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

      Might be a little too late, but you can add an if statement to the area with the GetAngle variable.

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

    Is there a reason to why some functions return a radian value while others return a degrees value?

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

    Easier chart to learn greater than school 🌝

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

    Wow, I understood all of it! Nonetheless, great video!

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

    Please make a video about quaternions.

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

    3:44 Wouldn't cos(0) = sin(90 + 0)?

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

    Some quality content damn

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

    Thank you so much for these amazing tutorials! :D Do you have any plans for Multiplayer/Networking?

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

      Chupachu that would be cool!

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

    Could you teach on how to make a sphere mesh based on this? I'm having problems converting 2D to 3D.

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

    BEAUTIFUL !!!!
    what software did you use to create the animations btw?

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

    great as usual

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

    Wow dude, your tutorials are premium stuff. But could you perhaps explain one tiny detail about how you do the conversions at 8:11 please?

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

      So after mulling over my problem, I think i might understand how you would get the angle in the opposing unit circle to whichever unit circle you are currently working with (which conventionally is the trig unit circle?). Anyway, from how i understand it, if the trig unit circle is the default, and the angle is 0 degrees. Converting the angle to unity's unit circle goes as follows:
      1) 90 - 0 = 90,
      2) Taking note that the result is a positive value, you should then "increase" the angle from the naught angle in the unity unit circle (or whichever unit circle for whom you are converting the angle).
      3) If the result were negative, e.g. if the angle to convert were 180, then
      90 - 180 = -90,
      which means you should "decrease" the angle from the naught angle in the unit circle of interest, or rather, "increase" in the opposite direction to how angles are usually incremented in that unit circle. Which in the Unity unit circle, where angles increase clockwise, you’d find this angle by "increasing" in the anti-clockwise direction from naught.
      Just my way of understanding. I would appreciate it if anyone could clear up any errors within it.
      Thanks for reading this far.
      Cheers

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

    More of these, please! :)

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

    please trigonometric with IK for example climb system

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

    other trig videos: *confusion*
    this trig video: tan = blue line : green line

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

    You're the best.

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

    Thank you

  • @GK-dw1fo
    @GK-dw1fo 3 роки тому

    You're fkin awesome dude!!!

  • @sb-jo2ch
    @sb-jo2ch 4 роки тому +2

    8:27 "which you can maybe imagine as some sort of weapon"
    yea right... weapon

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

    Great ! 💯 Thanks

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

    Great videos as always, but I just want to ask why question. Why are you not using normal letters like A B C... instead of feta ? English is not my first language and I think a lot of people will think like feta is some kind of special thing(I thought the same when I first saw feta in your videos), but then they discover that it's just a letter. I'm pretty sure it confuses a lot of people.

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

      Theta* The symbol represnets the angular position of a vector. Kind of like how X represents the the location along the "X-Axis" and Y represents the location on the "Y-axis". Yes technically you can substitute whatever symbols you want there. However then you have to explain what those symbols mean. By standardizing things like X, Y, Z and Theta you and everyone else immedietly understand what they represent. It confuses almost no one. Most people have already taken high school level math classes to know what theta is.

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

      I didn't finish high school yet that's why I left this comment. I just learned the most basic things about trigonometry like sine, cosine and tangent(even though I already knew those. Anyway thanks for the correction

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

      yw

  • @Jonas-vh3dz
    @Jonas-vh3dz 7 років тому

    Could you make a series about AI? Especially about a goal orientated AI like GOAP. I can only find good tutorials about state machines.

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

      Hey, a bit of a late reply, but if you want to dig deeper into AI I suggest this book : Artificial Intelligence: a Modern Approach. It really covers any AI you might need in a video game and more

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

    I now know why we were taught trigonometry from class 8 hehe

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

    syr cxr tyx is much harder to remember than Soh Cah Toa
    I feel like you should've mentioned opposite/adjacent/hypotenuse notation for this reason
    Also the fact that unity's angles aren't the same as the standard trig angles has given me so many problems in the past, it's so annoying.

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

      I was going crazy, thank you for highlighting that "Also the fact that unity's angles aren't the same as the standard trig angles has given me so many problems in the past, it's so annoying.
      "!

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

    excelent, thx

  • @777redhood
    @777redhood 4 роки тому

    how to do this for a 2d charcter top down

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

    THANK YOU!!!!

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

    very nice !

  • @fritiofrusck
    @fritiofrusck 7 років тому +6

    I'm just in 8th grade so this is super interesting

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

    Deep!

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

    finally that shit school math is worth now!!!

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

    Nice

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

    As some who studied a lot of high-level math, I find the unity coordinate system is very annoying

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

    POP! Brain fart! I've got goo leaking from my ear!

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

    Fuck you are so cool!

  • @maz5-870
    @maz5-870 3 роки тому

    This is how to teach MAth

  • @haph2087
    @haph2087 4 роки тому +2

    Hmm... It looks an awful lot like they mixed up cosine and sine when designing Unity, and never changed it to protect old code.
    And you cannot change my mind. Deal with it.

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

      They also mixed the axes in my opinion, in other 3d programs that i've used the z angle is up but no, Unity chose to go for the y angle, you gotta get used to it

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

    but the theta for the coordinates should be 180-120=60

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

    damn you make this too easy bro u should become a math teacher if it were good paying cough cough

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

    tnx who dare to dislike :(((

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

    o o f

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

    Are You Secretly a Genius?

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

    Am I the only guy who came here to learn math?

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

    .... WAT
    :P

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

    I cringed so hard when he pronounced the name of the greek letter XD