How to attaches a SpringArmComponent to a SceneComponent?


I’ve been doing unreal’s tutorial to create a camera from a pawn in C++:

The thing is, when I get to step 3 where I am asked to add this to the constructor:

RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
OurCameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 50.0f), FRotator(-60.0f, 0.0f, 0.0f));
OurCameraSpringArm->TargetArmLength = 400.f;
OurCameraSpringArm->bEnableCameraLag = true;
OurCameraSpringArm->CameraLagSpeed = 3.0f;

The third line ( OurCameraSpringArm->SetupAttachment(RootComponent); )
gives me an error saying that a USpringArmComponent does not have a member called SetupAttachment.

So here is my question : Guessing Epic hasn’t updated this tutorial, what is the “new” way to attach the SpringArm to the SceneComponent?

Hey DomClassic-

This documentation has been updated recently. You marked the product version that you’re using as 4.11, is that the current engine version you’re working on? If so then the issue is that the code from the documentation is newer than the version that you’re working with. Instead of SetupAttachment() you would need to use AttachTo(). If you update the project to 4.12 or later, you will need SetupAttachment() instead.