Created
April 7, 2023 22:22
-
-
Save r0xsh/ab13f808408f78abbe94bf961f07d98b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to run on each frame | |
function lerp(position, targetPosition) { | |
// update position by 20% of the distance between position and target position | |
position.x += (targetPosition.x - position.x)*0.2; | |
position.y += (targetPosition.y - position.y)*0.2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment