Hello, I’m new to unity and scripting and I’d like some help.
I want to ask: how do I make a script that would smoothly increase and decrease the FOV depending on the position of a target in the Y-axis? (I’m making a ball that jumps)
1 Answer
1I assume from your question you want to change the camera field of view from a script that is not attached to the target. The calculation would be something like:
Camera.main.fieldOfView = fov_basis + (y_basis + target.position.y) * zoom_factor;
You need to define or replace with hard-coded values ‘fov_basis’, ‘y_basis’ and ‘zoom_factor’. Depending on what you are trying to do, ‘zoom_factor’ may be negative.