Unity 3D USING Lerp vs MoveTowards vs SmoothDamp (In 2 Minutes)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so a little while ago i ran a little poll with the members and patrons to see what sort of game camera system they wanted to learn to make the most and of course they picked what i believe to be the most difficult kind of camera system to make but i'm a man of my word so i'm gonna do my best to simplify it for you however before i show you how to set up a third person camera you need to understand how to learn between positions now there are three main ways to transition between positions the standard is moved towards this is when one object moves to a position at a constant speed it's not smooth it's not fast it's constant the speed never changes the second method is lerpin just like larping with the number lerpin with the position starts off fast and then gets slower the closer it gets to the target the last method is called smooth damp and it's like alert but instead of starting fast and slowing down at the end it starts slow gets fast in the middle and then slows down as it gets to the end so what's the code for all this look like well luckily they all share very similar code let's start with lerp you'll need a transform or a vector3 to represent your target location then you'll need a float to represent your speed alright so to look from one position to another all you need to say is transform.position equals vector3.lerp transform.position targetposition and speed multiplied by delta time now all this means is that we want our object to alert from its current position to the target position at this speed if you save then drag your target object into the target variable and run the game you will now see our object slowly moves towards the target alright but what if you want to move at a constant speed well that's easy all you got to do is change lerp to move towards and if you run the game now you can see that our object no longer lurps from one position to another instead it's constant the whole way what about smooth damp what's that look like well it's almost the same but we need to add a variable up here for velocity then change the words down here from move towards to smooth damp and right in front of speed we add a comma to make space for a new variable save you're done something important to notice is unlike lerp and move towards where the slower speed is the slower the movement with smooth damp the higher the speed the slower the movement i don't know why it works this way but that's how you use it anyway hope that helps and as always hope you have a fantastic day and i'll see you around
Info
Channel: Royal Skies
Views: 48,383
Rating: undefined out of 5
Keywords: royal, 3d, animation, 3d model, model, character, tutorial, game, unity, unity tutorial, unity 3d, unity game design, indie dev, beginner, code, coding, c#, c# coding, program, programming, programming tutorial, coding tutorial, c# tutorial, c# programming, c# unity, ani, blender, variables, gameobject, object, move, movement, position, object movement, object position, transform, translate, local, local position, pos, lerp, vector, vector3, smooth, smooth damp, smoothdamp, movetowards, towards, lerp position
Id: gqU1t1jpmDw
Channel Id: undefined
Length: 2min 18sec (138 seconds)
Published: Mon Mar 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.