- Home /
Clamping values for camera bounds
Hi, I have what probably boils down to a very simple maths problem. Maths is not currently my strong point though.
I have two sets of values that need to be considered, the cameras field of view, which is clamped between 15 - 30.
And the cameras Y position which needs to be altered based on the field of view to be between 3 - 0 respectively.
So if the field of view is at 15, the cameras y position clamp will need to be 3, if the field of view is 20 the y will need to be 2 and so on up to the field of view of 30 where the y will need to be 0.
How would this be achieved? I think I just need a quick tip on the sort of equation that will cover this.
Thanks in advance.
As I am pressed to get this finished, I have already fixed it another way using the speed of the zoom to alter the 0-3 clamp too.
However if anyone comes across this and is willing to provide a small insight to the sort of equation that would have worked I would be very grateful as I really need to improve my maths skills.
Answer by Nido · Jul 28, 2015 at 01:50 PM
minFov = 15;
maxFov = 30;
fovRange = 15; // max - min
normFov = ((fovRange - currentFov)/15);
newYPos = (normFov * 3) + 3; //(unNormalized) + maxYPos
//With any enigmatic explanation, this is the formula
Thanks that makes sense. I will likely work that back into the project as a cleaner solution.