Camera will not follow player on positive x, y coordinates but will on negative x, y coordinates. What did I do wrong? I'm following this tutorial https://www.youtube.com/watch?v=b8YUfee_pzc&t=3612s and it looks like I copied it to the letter but I can't get it to work. (Code starts at 55:39 in the video)
public Transform lookAt;
public float boundX = 0.15f;
public float boundY = 0.05f;
private void LateUpdate()
{
Vector3 delta = Vector3.zero;
// This is to check if we're inside the bounds on the X axis
float deltaX = lookAt.position.x - transform.position.x;
if (deltaX > boundX || deltaX < -boundX)
{
if (transform.position.x < lookAt.position.x)
{
deltaX = deltaX - boundX;
}
else
{
delta.x = deltaX + boundX;
}
}
// This is to check if we're inside the bounds on the Y axis
float deltaY = lookAt.position.y - transform.position.y;
if (deltaY > boundY || deltaY < -boundY)
{
if (transform.position.y < lookAt.position.y)
{
deltaY = deltaY - boundY;
}
else
{
delta.y = deltaY + boundY;
}
}
transform.position += new Vector3(delta.x, delta.y, 0);
}
}`