Тёмный

Stop Using Lerp Wrong! Here's a Better Way 

RGBA
Подписаться 614
Просмотров 1,1 тыс.
50% 1

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

Опубликовано:

 

27 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@dmansor2
@dmansor2 3 месяца назад
i thought it was common sense to use lerp this way. what's the other way?
@rgba_dev
@rgba_dev 3 месяца назад
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
@FishSticker
@FishSticker 3 месяца назад
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
@rgba_dev
@rgba_dev 3 месяца назад
Freya knows everything about programming related math Didn’t know she had a talk on lerping but I would love to watch it!
@PipeSqueak-c9r
@PipeSqueak-c9r 3 месяца назад
Ah yes, always the correct way to learn. With Dora the explorer
@rgba_dev
@rgba_dev 3 месяца назад
the theme is 🔥🔥🔥
@Fine_Mouche
@Fine_Mouche 2 месяца назад
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)
@atomiz2002
@atomiz2002 3 месяца назад
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
@rgba_dev
@rgba_dev 3 месяца назад
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
@thepixelers9921
@thepixelers9921 3 месяца назад
Ah i see, i shall now use lerp using this method! 😮😅
@rgba_dev
@rgba_dev 3 месяца назад
To err is human; to use lerp correctly is divine
@nuclearcrow28
@nuclearcrow28 Месяц назад
You are missing one very very crucial aspect of using lerp() the regular way, and that is the fact that it's intentionally NOT an animation that has a start and an end - but rather something that keeps happening all the time every frame. When does this matter? This matters if the target moving itself is moving even while the "animated" object is approaching it. For example if we want something to smoothly trail along our cursor with a delay! You can't achieve that with an animation, because this motion doesn't have a start, an end, or a "state". This is the kind of task that the regular application of lerp in motion is used for. Your "reimagining" of the lerp technique is simply addressing an entirely different situation, for which indeed animation curves are better. So please don't be under the impression that the "normal" way of using lerp is somehow wrong - it is a perfectly good and powerful technique for many situations which you just seem to have not acknowledged. A separate note on the "never reaching the end value" issue that you outline - while it's mathematically true, for all practical purposes it's false. At t=0.5, within 20 iterations/frames the value error will be less than one millionth of the distance, which at our current monitor resolutions is not even visible in pixels with anti-aliasing. So it's quite literally of no consequence.
@timmygilbert4102
@timmygilbert4102 3 месяца назад
Someone had seen that Freya Holmer video too 😊
@rgba_dev
@rgba_dev 3 месяца назад
I actually haven’t haha but another commenter mentioned it too and I’ll probably watch it if I get the chance!
@felfar197
@felfar197 3 месяца назад
beautiful video!
@rgba_dev
@rgba_dev 3 месяца назад
thank you! I spend a lot of time on visuals
@spacehunter2018
@spacehunter2018 3 месяца назад
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!!!
@rgba_dev
@rgba_dev 3 месяца назад
thats what im saying fr everyone listen to this guy
@ThunderFound
@ThunderFound 3 месяца назад
Great video! Very informative
@rgba_dev
@rgba_dev 3 месяца назад
I’m glad it could help!
Далее
The Most Valuable File Format You've Never Heard Of
15:33
The Most Legendary Programmers Of All Time
11:49
Просмотров 565 тыс.
FATAL CHASE 😳 😳
00:19
Просмотров 524 тыс.
"Когти льва" Анатолий МАЛЕЦ
53:01
How do non-euclidean games work? | Bitwise
14:19
Просмотров 2,4 млн
Lab Exercise 2
2:29
Просмотров 3
How do modern games handle pixel art?
8:26
Просмотров 10 тыс.
OpenAI’s New ChatGPT: 7 Incredible Capabilities!
6:27
How to Make a Chess Bot in 10 Minutes
11:07
Просмотров 3,8 тыс.
9 Plot Mistakes Every New Fantasy Writer Makes
18:50
Просмотров 676 тыс.
Unity Checkpoints, Laps, and Times
30:57
Просмотров 5 тыс.
EVEN MORE Types of Programmers
6:06
Просмотров 143 тыс.
How Failing Fast Makes You a Better Programmer
4:53
Просмотров 3,1 тыс.
Beginner's Guide to the Bash Terminal
1:14:37
Просмотров 2,3 млн
FATAL CHASE 😳 😳
00:19
Просмотров 524 тыс.