- Home /
Smoother Camera Movement without making camera child of the player?
I am making a 2d endless runner. I have the camera always moving at the speed the character is supposed to be moving. However i want the camera to follow the character's y movement. when I make them equal eachother: transform.position.y=target.position.y
I get jerky camera movement when jumping. When i make the camera a child of the player it is perfectly smooth. Any ideas? I can post more script if needed.
What if you match the camera's y velocity to the player's y velocity? Then ins$$anonymous$$d of manually setting to the player's position each update, it will simply move upward (or downward) at the same speed as the player.
It would require some fine-tuning when the player lands on whatever surface he's on. Perhaps once grounded you could call your position code mentioned above?
Jerkiness can sometimes be an out-of-order problem. Like player moves in Update and camera in FixedUpdate. Or camera moves, then the player does (making the camera always slightly off by a random amount.)
Also, most people prefer a fast (anything 0.2 or more) Lerp ins$$anonymous$$d of =. That way, when you jump, you go a little but up on the screen before the camera tracks you. Feels more like you're moving.