- Home /
Question by
EvengerX · Jul 27, 2012 at 06:53 PM ·
zoomframetrigonometryfield of view
Trig function problem
Essentially i'm trying to get the distance of a gameObject from a camera to change so that it stays the same size (visually) in the camera's view as it's field of view raises and lowers.
I set up a trig function that should do this, but for some reason it doesn't;
distance = halfObjectHeight / Mathf.Tan(halfCameraViewAngle)
Is there something that I am doing wrong?
Also: The camera MUST zoom using field of view, I can't change that.
Comment
Answer by ScroodgeM · Aug 05, 2012 at 06:52 PM
distance = halfObjectHeight / Mathf.Tan(halfCameraViewAngle * Mathf.Deg2Rad);
Mathf.Tan function needs radians on input, FOV of camera uses degrees.
Your answer
