I’m working on a 2d game and having a problem scripting the camera controller.
basically what i’m trying to do is to make an if statement to check that if the camera x position isn’t as same as the main player x pos’, move the camera on the X axis towards the player.
problem is that the camera goes all blurry, because the camera move too much.
public void Camera_Controller()
{
float distance = Mathf.Abs(Vector2.Distance(player.position, transform.position));
if (distance > 0)
{
if(player.position.x < transform.position.x)
{
transform.position -= new Vector3(10*Time.deltaTime,0);
}
else
{
transform.position += new Vector3(10*Time.deltaTime, 0);
}
}
}