Ue4.20 c++ UCameraComponent how to set Field of view
Hello! I need help with UE 4.20 API. I just started to move my project to c++ and met with access restrictions by API. For Example: I created camera component in my custom pawn class, and tried to set camera fov property trough built in function SetFieldOfView(). But it turned out that it is private now. In official documentation sais that it should be public. I steel cant find any solution how to set Fov value. Another example: I created static mesh component and couldn't set material for it. Built in fucntion SetMaterial(int, UmaterialInteface*) also became private. Next example: UMaterialDynamic *->SetVectorParameterValue () also is private.
I already read documetation, saw huge amount of tutorial in web, but it seems like that they are using compleatly different engine. I also checked all realise notes for every engine version and couldn't find solution. So i don't understand what is happened to engine API and what i should do to work with it. If anybody knows how to set those params, please help me. Thanks in advance.
asked Sep 01 '18 at 03:11 PM in C++ Programming
It seems I figured it out. I use Visual Studio 2017 for work, which uses standard C ++ rules to parse the code and shows an error when trying to use private functions.The IntelliSense mechanism relies on it. Apparently UE4 uses its own version of C ++, in which functions are explicitly undeclared as private, successfully compiled and run in the engine. Then my question is removed. Now everything works, despite earlier the compiler gave an error. IntelliSense errors can be ignored. Thank you for your help!
The correct function is CameraComponent->SetFieldOfView(FloatValue); Be sure to declare the CameraComponent in your header file and to attach it to the SpringArmComponent or whatever Component you wish to attach your Camera to.
You may want to read the code and do some testing within the FirstPerson or ThirdPerson template where all elements are already set and ready to use.
answered Sep 01 '18 at 03:38 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here