How to get reference to the Camera in C++ which I attached in the Blueprint?

I added the spring arm and the camera in the character Blueprint.
Now I need to access it in the Character CPP file to set various things in code.

APlayerController* ShooterPlayerController = Cast<APlayerController>( Controller );
ShooterPlayerController->PlayerCameraManager->ViewPitchMin = -MaxAngle;

IS this correct or is there a better, more efficient way to do this?

If you know you need those component, why not add them directly in your cpp?
This way you will see them in BP and manipulate them via C++

This should put you on the right track:
https://unrealcpp.com/add-component/

1 Like

Makes sense. But this was from a tutorial where the lecturer adds them ib BP and later on in the course uses a cpp version. This the code I used to get the reference. What you say is the best approach! Thanks.
Can I add the cpp code even after I have added the components in cpp, so that I can have easy references in cpp?