the function works perfectly when the player stands still. Moving seems to shift the camera, which also shifts the calculated canvasPos https://user-images.githubusercontent.com/30176357/194759199-cba5f476-d212-4173-a8be-94f65263ee63.mp4