- Home /
Camera follow Player Car - 2d game
I want my camera follow to my Player Car. But its not showing smoothness in actual device. There is no problem of FPS because its really small game. So definitely its camera movement related issue.
In Unity editor its moving nice but on actual device movement was not that much good so that I can say smooth. Here is my simple code that I was using:
void Start ()
{
offSet = target.position - transform.position;
}
void LateUpdate ()
{
Vector3 cameraPosition = target.position - offSet;
cameraPosition.x = 0f;
// cameraPosition.z = -10f;
transform.position = cameraPosition;
// transform.position = Vector3.Lerp (transform.position, cameraPosition, Time.deltaTime * smoothness);
}
There are many camera following related code exist but those are really complex so I don't prefer those. I want really simple that understood by every one clearly.
Please give me some suggestion for this.
EDIT: Now some sort of time spent with same, I have following code but its still require improvements.
float smoothTarget = Mathf.SmoothDamp (transform.position.y, target.position.y - offSet.y, ref velocity, smoothness); Vector3 cameraPosition = transform.position; cameraPosition.y = smoothTarget; transform.position = cameraPosition;
Still there is noticeable jerks in movement.
Answer by Jip1912 · Nov 07, 2016 at 10:51 PM
Doesn't it work if you just make the camera a child of the player car.
Your answer
Follow this Question
Related Questions
Cinemachine 2D - How to reset lookahead 1 Answer
How to make a camera Follow an Object moving in zigzag path? 1 Answer
Camera Follow (Not Exact) 1 Answer
how the camera will follow the rotation in one axis only? 1 Answer
Why Child's Local z position is changing when I change z of my camera. 1 Answer