How to use Sin Cos in Unity - A Unity Math Tutorial

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

КОМЕНТАРІ • 120

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

    Have a tutorial suggestion? Let me know here in the comments and join our discord! discord.gg/Sk4M3Y3

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

      about physics, Newton's laws of motion and how to apply into Unity

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

      @@angeldiaz7554 Great suggestion!

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

      long playlist on applying calculus with unity

    • @5252emre
      @5252emre 4 роки тому

      about gear shifting were interresting

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

      If you could do a raycasting toturial I think that would be amazing!

  • @ImBoyCryWolf
    @ImBoyCryWolf 3 роки тому +3

    Dude this was perfect, I keep seeing sin and cos used in Unity tutorials where they don't bother to stop and explain them at all, this helps so much.

  • @gamefactory.official
    @gamefactory.official 4 роки тому +1

    I am confused why this channel is not ahead of every other!!!!

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

    +1000 thumbs for this! 20 years later and now I finally understand how Sin and Cos are used for creating animation for games! =)

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

    I never think about Why the circle motion C coordinate is relative with Cos until I watch this video. Your explain so clear and very suitable for all programmers and math lovers.

  • @Re.Zero.07
    @Re.Zero.07 Рік тому +2

    fun fact: you can easily make a weapon/head bob animation with sin waves instead of making an animation with blendspaces

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

    Today I Understand this very deep Thank Jason Weinberger this is the best math series I ever come across you deserve more subscriber

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

    Absolutely amazing! With these tips I compressed my code from 50 lines to only one line, thank you so much! note: I used Time.deltaTime instead of Time.time and that made the frequency way faster and jittery so if anyone struggles with the same problem just switch the time value as shown in the video.

  • @cgcowboy
    @cgcowboy 5 років тому +21

    Fantastic! I never thought I would appreciate math so much. I wish my high school math teach could have explained things this way. Love the math series, the level of detail, and how you are applying it in real life development. Keep 'em coming and thank you!

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

      Thanks for watching, mate! More to come! :)

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

    Great tutorial. Thank you for using C# naming conventions and not needlessly giving the floats public access.

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

    this is cool - I adapted mine to show the angle too as it goes around

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

    cant watch another video without letting know u tht u r the best teacher

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

    So far it looks nice I'm still attempting to understand all the different uses

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

    Wow! I never thought I'd actually understand this! Thank you! I'd love to learn how to work with these algorithms so I can create more complex movement. Thank you!

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

    more about this topic please. your course is very to understand.. you’re the best

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

    Thank u so much sir it's really helpful we need more math

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

    I watched a lot more videos and couldn't get it, but now I feel they are so easy 😂
    Thanks a lot

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

    thank you for this
    currently learning your survival guide on unity

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

    thanks for providing the graph and paint, helped me visualize :D

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

    Hi Jonathan , I just wanted to say thank you for these tutorials, they're incredibly useful and a lot of fun. I've been working through all your Udemy courses and they've really helped me become a competent developer. Keep up the great work and I would love more math videos!

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

      Thanks Craig! That's awesome. More math videos to come! :)

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

    Woah! I now understand sin and cos! Thanks man, much appreciated!

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

    Very clear explanation. Thank you!

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

    I love your detailed explanation. Thank you so much

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

    we need more video like this plsss

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

    Ohhh man thank you! I don't know any math, but i understood most of your lesson! Great job my bro! Thanks!

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

    This video is a godsent ! Thank you very much. Very clear and professional.

  • @СашаПономарев-е7ъ
    @СашаПономарев-е7ъ 4 роки тому

    That was god damn brilliant, I wish you had more these lessons about mathf tricks and how to use other methods in games.💪💪💪

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

    Please make more of these

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

    I like how hes recording this at 1 am

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

    Great content! Thxs alot for the these tutorials.

  • @MohamedHassan-yw1hh
    @MohamedHassan-yw1hh 5 років тому

    Really u deserv more views u made this sooo easy to understand. Thank you GameDevHQ I will subscribe and support u!

  • @MeMe-nm7jr
    @MeMe-nm7jr 4 роки тому

    Ughh, hate that I forgot my Trig lol, but this was a perfect tutorial to give me exactly the info I needed. Thanks!

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

    this is really awesome knowledge! Please continue working on this.

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

    Thanks! would like more math videos

  • @Ghost-zk6ny
    @Ghost-zk6ny 2 роки тому

    Great tutorial man!

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

    Please more math videos, I love it!!!!

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

    Hey if you re having a problem about viewing the video change the quality .

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

    Thank u sm, this really helped me out!!!!

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

    Amazing Tutorial, Superb.

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

    Thanks its nice, it just refresh my maths skills

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

    It was really helpful, keep up the good work

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

    Fantastic, thank you. Love your courses, and your method of teaching, you have an excellent way of explaining things in a progressive and effective way. Please tell me you have more of these math tutorials coming out (or even better, a course as part of your series)

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

    Your tuts are so good.
    Shame about the low view count.
    I’ll be sure to share it.

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

    From math perspective, this is really ruined my understanding of "waving" , but in good terms . This video sort of expanding my imagination . Thanks !

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

    Awsome tutorial 🥳

  • @Alexandre-rt7xk
    @Alexandre-rt7xk 4 роки тому

    Great tutorial man, many thanks!

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

    Thanks for making maths easy. Sir please make more video about maths.

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

      Thanks for watching!

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

    Another great video, presented in an easy to understand and enjoy manner. This series is spectacular, it belongs on your paid udemy course, btw those are great too. Can't wait to see the next one, cheers.

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

    Excellent video

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

    that useful, thank you so much

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

    Amazing! We want more!
    Thank you

  • @ShubhamRathod-v8o
    @ShubhamRathod-v8o 10 місяців тому

    its clear thak you buddy, i liked your video and also subscribe you channel

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

    Amazing! started to love math!

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

    nice that's really good!

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

    Thx Sensei!

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

    This helped a lot, I am make boids so I needed some ray casts in a circle :}

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

    Thank you!

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

    best video about this topic,thx you much

  • @Max-jk9pp
    @Max-jk9pp 5 років тому +2

    Is there a similar video like this but with Abs?

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

      mathf.abs(-1) = 1
      mathf.abs(1) = 1
      it just makes negative number positive

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

    Great video. How about Lerp!!

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

      We can definitely add a video for LERP.

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

    Ty! Ty!

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

    You are the best

  • @In-N-Out333
    @In-N-Out333 5 років тому +4

    Any chance you can show us how to create a color spectrum that we can use as a power meter? So it would go from green to red depending on how fast we move the mouse to hit the ball or how loudly we talk into the microphone?

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

      Great suggestion! I'll add it to the list!

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

    It would be more efficient to use a taylor series with less terms tough. If you have a lot of ghosts levitating it could create lag altough I am not sure how bad. With just a few terms you already get pretty close.

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

    What if i wanted it relative to the position i allready assigned? Like, right now it's bound to revolve around 0 x and 0 y. If i want whatever x/y i moved it to in editor + revolve?

  • @thesejo.6691
    @thesejo.6691 3 роки тому

    More please

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

      gamedevhq.com/video-page

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

    thank you oh good man!!!

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

    Awesome

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

    This is so cool, thanks!!
    One question, which one is better in terms of performance: Animation or Sin/Cos or tween?

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

    Cool!

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

    Obrigada! ótimo vídeo.

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

    I really was worried about Sin(x) and Cos(x) before watching your tutorial, this sin(x) and cos(x) moving ghost lets say vertically or horizontally what if we want to move it "in or out" it would be more convenient if i say on Z direction

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

    great tut,but I have a question!) When we use circular movement transform position starting at the right point of out x variable,how can I make it start from the original position?

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

    Hey Great video, how do I change value from 1 to 0 only , instead of 1 to -1

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

      lol, that's not how sine waves work

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

    This is awesome! Thank you. Two questions. Why did you use Time.time instead of deltaTime and is there a reason you start your variables with underscores?

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

      Time.Time is how long the game has been running. It's a continuous incrimental timer. Time.deltaTime is the time it takes between frames. Often used to smooth things out.
      I use underscores on private variables. It's a microsoft standard. When you're 1,000 lines of code deep, seeing the underscore tells you it's a private variable

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

      @@gamedevhq Awesome! Thanks!

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

    Your are awesome

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

    why the object always go to zero positi

  • @Garfield_Minecraft
    @Garfield_Minecraft 9 місяців тому +1

    i'm coding AI

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

    Helpful, thanks, sub+

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

    Where is it?

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

    Hey this is so nice. I just wonder if I can control all of my objects with a single script or do I have to attach this script to all my platforms? :)

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

      I sorta had a solution but al the objects go to the 0 point of the Y axis of the scene. But at least they all float.

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

    here's my modded cube from Unity Learn using randomized sinewaves if anyone wants to have a gander.
    public class Cube : MonoBehaviour
    {
    public MeshRenderer Renderer;

    //rotation
    public float xRot, yRot, zRot, wRot;
    public float rotSpeed;
    //sinwave positioning
    public float xPos, yPos, zPos;
    public float xAmp, yAmp, zAmp;
    public float xFeq, yFeq, zFeq;

    void Start()
    {
    fnRandomize();
    transform.position = new Vector3(xPos, yPos, zPos);
    transform.localScale = Vector3.one * 1f;

    Material material = Renderer.material;

    material.color = new Color(0.5f, 1.0f, 0.3f, 0.4f);
    }

    void Update()
    {
    fnTransform();
    fnRotation();
    }

    public void fnRandomize()
    {
    xPos = Random.Range(-1.0f, 1.0f);
    yPos = Random.Range(-1.0f, 1.0f);
    zPos = Random.Range(-1.0f, 1.0f);
    xRot = Random.Range(-1.0f, 1.0f);
    yRot = Random.Range(-1.0f, 1.0f);
    zRot = Random.Range(-1.0f, 1.0f);
    xFeq = Random.Range(.1f, 2f);
    yFeq = Random.Range(.1f, 2f);
    zFeq = Random.Range(.1f, 2f);
    xAmp = Random.Range(1f, 20f);
    yAmp = Random.Range(1f, 20f);
    zAmp = Random.Range(1f, 20f);
    }
    public void fnTransform()
    {
    xPos = Mathf.Sin(Time.time * xFeq) * xAmp;
    yPos = Mathf.Sin(Time.time * yFeq) * yAmp;
    zPos = Mathf.Sin(Time.time * zFeq) * zAmp;
    transform.position = new Vector3(xPos, yPos, zPos);
    }
    public void fnRotation()
    {
    transform.Rotate(xRot, yRot, zRot);
    }
    }

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

    Somebody's been taking Penny de Byl's courses.

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

      Ha. I've never actually taken a course from her, but we're friends! :)

  • @john.watson
    @john.watson 5 років тому

    👍

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

    😃👍

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

    Thank God for 1.5x speed

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

    пиздец, как учится unity, когда все видео иностранные

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

    Thanks a lot for your videos, they are all very helpful! I'm having an issue with a strafing movement and came up to this one. This seams to be the path where I should go but can't figure out how to apply this to my problem. Would you mind having a look and hopefully put me on the right track?
    Here is the link: forum.unity.com/threads/strafing-movement-with-lookat-enemy.866725/

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

    unity says that mathf doesn't exist

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

    Maths ! Not Math ... grr

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

    3:25 Erm... That, sir, is a "right-angled" triangle. All triangles are "right"... if you're doing them "wrong", they're not triangles at all. Good day!

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

      nope

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

      ​@@gamedevhq At 4:05: in maths, you should really curl your x as if it were a backward "c" and "c" together. Otherwise it just looks like a multiplication sign. I believe these things are important when you're teaching.

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

      @@lozD83 nah

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

      @@gamedevhq ...How about pronouncing "axis" correctly?

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

      @@lozD83 nerd