# Get BP FollowCamera Rotation and Location

I'm accessing my FollowCamera https://imgur.com/a/vbFagxg from my BluePrintCharacter class in my C++ code, with this following line :

FollowCamera = GetOwner()->FindComponentByClass<UCameraComponent>();
FVector WorldLocationV = FollowCamera->GetWorldLocation();


But when I run my game, I get this error : GetWorldLocation is not a member of UCameraComponent

Why is this, and how can I get GetWorldLocation from FollowCamera in C++?

In BluePrint this seems to work fine : http://i.imgur.com/8m9TWUW.png

• I think you should be casting your found component --- FollowCamera = Cast<UCameraComponent>(FindComponentByClass<UCameraComponent>()); Mar 27, 2020 at 10:11

According to the Unreal docs UCameraComponent you are correct, GetWorldLocation isn't part of UCameraComponent.

Attached to the camera is a camera manager and to get the world location and rotation of the camera, you need to get this.

APlayerCameraManager *CameraManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;

FVector CameraLocation = CameraManager->GetCameraLocation();
FVector CameraForwardVector  = CameraManager->GetCameraRotation().Vector();
`

In case you need it, the #include is #include "Camera/PlayerCameraManager.h"

• This is incorrect - GetWorldLocation is a member function of USceneComponent, which UCameraComponent derives from. Your approach for getting OP's desired output would work however Mar 27, 2020 at 10:17