Sorceress

gliding camera physics

Jul 11th, 2015
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. k = 2; // some number that controls the snappiness of the camera
  2. offset = 480; // where you want the camera to settle relative to the player
  3.  
  4. camera.targety = player.y + offset;
  5. if(camera.targety > camera.y)
  6.   camera.velocity.y = (camera.targety - camera.y) * k;
  7. else
  8.   camera.velocity.y = 0;
  9. camera.y += camera.velocity.y * deltatime;
Advertisement
Add Comment
Please, Sign In to add comment