I have a dilemma that I did not have in XNA before porting my game to Unity.

First-- my goal is to mimic Super Mario World 2's camera tracking in x. The camera tracks to 1 block ahead of the player, to the left or right, depending on the direction, even if the player stops moving during the camera tracking process, otherwise I would simply make the camera a child of the character and then be done.

As the speed of my character increases, the camera drags behind. The distance (lag) between the camera and the player increases with speed, but catches up instantly when the player stops moving. I figure this is because the FixedUpdate call is somehow getting the last player position from my controller script.

This did not occur in my XNA project, and the algorithms are essentially the same.

cameraTargetX = position.transform.x - margin;

in this case the margin would be +2 blocks or -2 blocks depending on direction. Even if I get input for movement into fixed update in my player script, I still get the same delay amount. Is there a way to essentially lock the camera to a position directly in front of or behind the player without gradual delay?

If one could point me to an example of a detailed or elaborate 2D platformer with similar camera controls, that would be much appreciated since the Unity 2D example platformer's camera script is really nothing like what I'm trying to do here.

Update the camera position in the LateUpdate method. This will account for the position of the character after it has moved.

When updating in fixed update or in update, the position of the camera is being set to the position of the character before it's moved. This means that the more it moves per frame (its speed), the farther behind it lags.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.