Sorceress

gliding camera physics

Jul 11th, 2015
304
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data