Unreal 4.23 unable to build C++ tutorial code

Hi folks i’m new to unreal i’m doing the C++ tutorial from here :
https://docs.unrealengine.com/en-US/…2/7/index.html
All work fin until the code set the camera in the class, here there is an error, i got the FULLY copied source from the tutorial
here is the error :

  • UPROPERTY(VisibleAnywhere)
  • UCameraComponent* FPSCameraComponent;

hope you can help,

thanks,

f.

You didn’t write what the error is? Is it that UCamerComponent is undefined?

make a forward declaration to UCameraComponent by appending class like this


UPROPERTY(VisibleAnywhere)
class UCameraComponent* FPSCameraComponent;


Hi Garner i’ll managed to fix the problem with including :

#include “UObject/ObjectMacros.h”
#include “UObject/ScriptInterface.h”
#include “Components/SceneComponent.h”
#include “Engine/BlendableInterface.h”
#include “Engine/Scene.h”
#include “Camera/CameraTypes.h”
#include “Camera/CameraComponent.h”
#include “Components/SceneComponent.h”
#include “GameFramework/Character.h”
#include “FPSCharacter.generated.h”

Now i have an error on :

FPSCameraComponent->SetupAttachment(GetCapsuleComponent());

error C2664: ‘void USceneComponent::SetupAttachment(USceneComponent *,FName)’: cannot convert argument 1 from ‘UCapsuleComponent *’ to ‘USceneComponent *’

TIPS : Visual assist told me that UsceneComponent is incompatible with UCapsuleComponent

Hope you can help, i really want to dig this engine, did you know some good C++ tutorial for UE 23.1 ?

ok i’ve found you have to include

#include “Components/CapsuleComponent.h”

Thanks all ; =)

Please how to set thread as “resolved” ? seeked on the web dont found

I have the same problem according to the lesson https://docs.unrealengine.com/en-US/Programming/Tutorials/FirstPersonShooter/2/7/index.html

I had exactly the same problem. The lesson 2.7 - Changing the Camera View | Unreal Engine Documentation is totally broken.

This will always happen to you. Now you have to add the specific header of most types that you use in each cpp you make. Previously they used a header include that implicitly included many modules. Now you include what you need.