How to join a camera to an object?
Parenting the camera to the object will solve this problem. You can do this by selecting the camera first, and then selecting the object you want to parent it to. You can parent by pressing CtrlP, and then selecting object (keep transform). This should fix the problem.