V
V
Vladimir Dubos2018-02-07 22:18:35
C++ / C#
Vladimir Dubos, 2018-02-07 22:18:35

How to control camera in Unity from C# script?

Good day! The following problem appeared: I am making a simple program (the cylinder rotates and rotates in a special way), it is necessary that the mouse wheel can be used to "zoom". I found the required parameter in the camera properties, but I didn’t find how to change it from the C# code. You need to somehow define the desired instance of the Camera class (this is not a meaningless set of buzzwords?).
PS: I have minimal experience in c#, but I see the unit for the first time and I don’t plan to work in it anymore, so I need the simplest tool, "crutch" or "bike"
PPS: Thanks to Daniil Basmanov for the solution. If someone needs it - here is the "zoom" code using the mouse wheel, it must be put in Update():

Camera.main.fieldOfView -= Input.GetAxis ("Mouse ScrollWheel");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-02-07
@vovaduba

The camera API can be viewed here , and the main camera tagged with MainCamera can be found using Camera.main . Get something like:Camera.main.fieldOfView = 30;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question