Stop Using Lerp Wrong! Here's a Better Way

Sdílet
Vložit
  • čas přidán 21. 06. 2024
  • A common mistake beginners make when using Unity's Lerp function for moving objects is keeping t, the blend factor, constant. While this does still work, it causes some problems that might affect you.
    In this video I'll show you a much better way to implement lerp where you can also add your own custom smoothing using an AnimationCurve.
    I felt like doing something new for the intro, hope you liked it lol
    This is the dora theme remix I played: • Dora The Explorer (OFF...
  • Věda a technologie

Komentáře • 20

  • @user-tx1bg7hy8v
    @user-tx1bg7hy8v Před 20 dny +5

    Ah yes, always the correct way to learn. With Dora the explorer

  • @FishSticker
    @FishSticker Před 17 dny +2

    To anyone saying he’s strictly using it wrong, the original use case still has great utility for smooth exponential chasing, Freya holmer (queen of linear interpolation) has a whole talk about this and how to frame rate sync

    • @theunknown1050
      @theunknown1050  Před 17 dny

      Freya knows everything about programming related math
      Didn’t know she had a talk on lerping but I would love to watch it!

  • @dmansor2
    @dmansor2 Před 21 dnem +5

    i thought it was common sense to use lerp this way. what's the other way?

    • @theunknown1050
      @theunknown1050  Před 21 dnem

      The other way is to keep t constant and set the starting position to the current position of the object being moved.
      It causes the two problems mentioned in the video (non linear movement and the object not actually reaching the target position)
      Some people are introduced to this method for smooth movement through tutorials and never learn otherwise. While it’s not exactly wrong, it’s much better to use the method I show in the video imo

  • @Fine_Mouche
    @Fine_Mouche Před 11 dny

    I want to make a game since 2015, but i'm so noob i currently only do it with numerically (a set represent edge and another set represent the path) (and even this i had struggle to do it).
    It would be game where we move along the sides of polygons leaving a trace of a certain color, we can go back this will trace [[above/beside] / this will make another floor ] and when we have gone around the polygon respecting the rules*, this changes the color of the trace and saves it if it does not already exist.
    (*ex: no more than 2 round trips on the same segment/side)

  • @thepixelers9921
    @thepixelers9921 Před 22 dny

    Ah i see, i shall now use lerp using this method! 😮😅

  • @timmygilbert4102
    @timmygilbert4102 Před 16 dny

    Someone had seen that Freya Holmer video too 😊

    • @theunknown1050
      @theunknown1050  Před 15 dny

      I actually haven’t haha but another commenter mentioned it too and I’ll probably watch it if I get the chance!

  • @spacehunter2018
    @spacehunter2018 Před 23 dny +1

    very informative and educational, someone like me who has never touched any form of code before can easily understand this. very nice! Very great! very awesome!!!

    • @theunknown1050
      @theunknown1050  Před 23 dny

      thats what im saying fr everyone listen to this guy

  • @ThunderFound
    @ThunderFound Před 21 dnem

    Great video! Very informative

  • @felfar197
    @felfar197 Před 21 dnem

    beautiful video!

  • @atomiz2002
    @atomiz2002 Před 20 dny +5

    this video seems more of an explaination to your misunderstanding of how lerp works because you closed the tutorial you were following as soon as the line of code at the beginning was written...you cant title a video stop using lerp wrong when youre the one using it wrong rather than the massively acceptable way

    • @theunknown1050
      @theunknown1050  Před 20 dny +1

      Sorry if I’m misunderstanding your comment but I had no tutorial open at the start lol the video on my laptop was something I made so I’m not completely sure what you’re talking about