x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

Product Version: UE 4.20
Tags:
more ▼

asked Sep 01 '18 at 03:11 PM in C++ Programming

avatar image

Supreme.net
35 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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!

more ▼

answered Sep 01 '18 at 06:07 PM

avatar image

Supreme.net
35 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Sep 01 '18 at 03:38 PM

avatar image

TheDreamCatcher
263 2 4 5

avatar image Supreme.net Sep 01 '18 at 04:06 PM

Hi! I already took into account all this added all the necessary inclusions in the header file. And I also know the signature of this function. Here is my header file screen: alt text

I checked the implementation of similar functions in FirstPersonTemplate and there the compiler also produces an error. Apparently these samples were written in an earlier version of the engine.

Here is a screenshot of the UCameraComponent class declaration from version 4.20. alt text

This function, like many others, does not have a public specifier. Therefore, according to the rules of c++ they automatically become private. The question is why is that and how to work with this now?

avatar image TheDreamCatcher Sep 01 '18 at 05:49 PM

Don't you have already all these components inside the ACppMasterPawn?

avatar image Supreme.net Sep 01 '18 at 05:57 PM

No, my class derived from pawn, wich is doesn't contain these components. If I used the character class as the parent, then I already would have these components. But it is not my choice, since i don't need character movement component.

avatar image TheDreamCatcher Sep 01 '18 at 06:09 PM

when you declare CameraComponent I suppose you follow the usual path aka: CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));

avatar image Supreme.net Sep 01 '18 at 06:18 PM

Yes, of course. Mine looks like: MainCamera = CreateDefaultSubobject(TEXT("MainCamera"));

Actually i found what was problem. I posted answer on top. Thanks for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question