Skip to content

Instantly share code, notes, and snippets.

@r0xsh
Created April 7, 2023 22:22
Show Gist options
  • Save r0xsh/ab13f808408f78abbe94bf961f07d98b to your computer and use it in GitHub Desktop.
Save r0xsh/ab13f808408f78abbe94bf961f07d98b to your computer and use it in GitHub Desktop.
// 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