Lerping Fundamentals - Learn How to Use It & When to Use Its Variants | Unity Tutorial

Поділитися
Вставка
  • Опубліковано 31 лип 2024
  • Lerping is one of the foundational things you need to know about in video game development! There are so many use cases for lerping it's impossible to name them all! Almost any time you want to rotate, move, or change a value over time, lerping is an option.
    💸 Ongoing sales 💸
    ⚫ See all active asset sales on the Asset Store: assetstore.unity.com/?on_sale...
    ⚫ Save 25% off your first Asset Store Order: prf.hn/click/camref:1101l9QvC...
    ⚫ Save up to 50% on NEW Assets: assetstore.unity.com/?new_sal...
    👨‍💻 As always, all code from this video is available on GitHub: github.com/llamacademy/lerpin...
    ❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or UA-cam Member:
    ⚫ Patreon: / llamacademy
    ⚫ UA-cam Member: / @llamacademy or click the Join button on any video
    📚 Resources 📚
    ⚫ Vector3 Lerp: docs.unity3d.com/ScriptRefere...
    ⚫ Quaternion Lerp: docs.unity3d.com/ScriptRefere...
    ⚫ Quaternion Slerp: docs.unity3d.com/ScriptRefere...
    ⚫ Color Lerp: docs.unity3d.com/ScriptRefere...
    ⚫ Mathf Lerp: docs.unity3d.com/ScriptRefere...
    ⚫ Wikipedia Slerp & Lerp: en.wikipedia.org/wiki/Slerp
    ----
    Most tutorials come from knowledge gained making survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
    I also have some Unity Assets (affiliate link): assetstore.unity.com/publishe...
    Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
    #unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
    Chapters:
    00:00 Lerping Introduction - What is Lerp?
    03:05 Vector3.Lerp - Fixed Time
    04:15 Vector3.Lerp - Fixed Speed
    05:37 Use Case for Fixed Speed Vector3.Lerp
    06:07 Quaternion.Lerp and Quaternion.Slerp
    07:34 Fixed Speed Rotation
    08:45 Color.Lerp
    09:39 Final Thoughts

КОМЕНТАРІ • 44

  • @protox4
    @protox4 2 роки тому +13

    Another common use for lerp is a smooth follow script, where the object moves towards its target and automatically slows down as it gets closer. This is done in an update timer constantly every frame, plugging its own position in for a, with a fixed t (which can be increased or decreased to adjust the speed).

  • @djpersonalspace2406
    @djpersonalspace2406 Рік тому +2

    Brilliant tutorial. Thanks so much for this!

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

    Nicely done sir! Really enjoyed this. Some great, clear examples!

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

    exactly what I was looking for, thank you for the clear explanation!

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

    This is really great. Well explained!

  • @a.technology1446
    @a.technology1446 2 роки тому +1

    This is amazing, thank you

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

    what an amazing guy

  • @Jam-ht2ky
    @Jam-ht2ky 2 місяці тому

    thank you

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

    great tutorial, that really helps my dream become a reality :)

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

    Thanks so much!

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

    how can i use it for fixed speed vector3.lerp???

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

    Thanks

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

    Thanks , amazing tuto ,
    Can you please make a tuto for :smooth swipe movement (left _right ) like runner games of casual games ?
    Thank you again ❤

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

      I'll add it to the list of topics to cover!

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

    How would you go about making an object go from one point to another, but speed up as it gets closer to its destination?

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

      I would do this with an AnimationCurve. In the future more advanced lerping tutorial I'm planning I'll cover that in more depth. But essentially you can define a
      [SerializeField]
      private AnimationCurve LerpCurve;
      and instead of passing time directly into the lerp, you can use LerpCurve.Evaluate(time);

  • @Zify.z
    @Zify.z 4 місяці тому

    How do you lerp the cube between the two circle continuously for lerp with time?

    • @LlamAcademy
      @LlamAcademy  4 місяці тому

      you can have a MonoBehaviour that lerps from one to the other and track which one it should be going to

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

    I know how to Lerp, but I need to know how do I Lerp from A to B, then from B to C? Where do I put this code and do I need a coroutine to do this?

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

      If you want a 3 point lerp from A-> B -> C the easiest way to handle that is a coroutine (or update loop) just lerping exactly like you said, wait until you hit point b, then update to go to point C using B as the starting point for the second starting point and resetting your timer variable!

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

    any idea how could i rotate an object with an overshoot? something like a elastic (springeffect)?

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

      I have a video on springs here: ua-cam.com/video/6mR7NSsi91Y/v-deo.html

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

      @@LlamAcademy nice. thank you

  • @watercat1248
    @watercat1248 4 місяці тому

    Do you have have toutoria about this shooting system 5:39
    It's very important for my to understand how to make shooting system for my game.

    • @LlamAcademy
      @LlamAcademy  4 місяці тому +1

      Yup, here it is Bouncing Bullets with Hitscan Guns | Unity Tutorial
      ua-cam.com/video/GkStW8-Q5P0/v-deo.html

    • @watercat1248
      @watercat1248 4 місяці тому

      @@LlamAcademy thenks

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

    The file in GitHub is all pink as I import it in unity

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

      🤔 are you using HDRP or URP? This repository was using Built-In Render Pipeline. That's just a guess

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

    One thing I would have liked to see is lerping a scale

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

      Scale works the same as position, since it is a Vector3. You can use the exact same code, but assigning to transform.localScale property instead of transform.position property

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

    good tutorial but without complete scripts it's difficult for new learners like me.

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

      Full project is on GitHub. Link in description

  • @user-nn3dc3jg9y
    @user-nn3dc3jg9y 6 місяців тому

    Lerp, Slurp and Leripng, all sound like rick and morty made-up words

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

    me yes me

  • @maxst9561
    @maxst9561 11 місяців тому +1

    you can fricking lerp colors? 😅😅😅😅