Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- k = 2; // some number that controls the snappiness of the camera
- offset = 480; // where you want the camera to settle relative to the player
- camera.targety = player.y + offset;
- if(camera.targety > camera.y)
- camera.velocity.y = (camera.targety - camera.y) * k;
- else
- camera.velocity.y = 0;
- camera.y += camera.velocity.y * deltatime;
Advertisement
Add Comment
Please, Sign In to add comment