I have this code below that basically what I want to do is when my players y distance from the floor increases I want my camera to zoom out. The camera script works as well as the code below. The only problem is when i have more than one distance value like below it will skip the first distance value and wait until i reach the second one. Are my if statements incorrect?
function Update()
{ //Camera Zoom out when player reaches certain height
var distance = Vector3.Distance(floor.position, Target.position);
if (distance > 19.3f)
{
cameraDistance = 22
}
if (distance > 22)
{
cameraDistance = 24;
}
else
{
cameraDistance = 20;
}
}