I try to prevent my camera from moving for ever, so I want to add somthing like “borders”.
I tried this, but it gives me errors.
How should I fix it?
if(Camera.main.transform.position >= Vector3(worldBorderX, transform.position.y, transform.position.z))
{
Camera.main.transform.position = Vector3(worldBorderX, transform.position.y, transform.position.z);
}
if(Camera.main.transform.position >= Vector3(transform.position.x, transform.position.y, worldBorderZ))
{
Camera.main.transform.position = Vector3(transform.position.x, transform.position.y, worldBorderZ);
}
if(Camera.main.transform.position <= Vector3(-worldBorderX, transform.position.y, transform.position.z))
{
Camera.main.transform.position = Vector3(-worldBorderX, transform.position.y, transform.position.z);
}
if(Camera.main.transform.position <= Vector3(transform.position.x, transform.position.y, -worldBorderZ))
{
Camera.main.transform.position = Vector3(transform.position.x, transform.position.y, -worldBorderZ);
}