4.8.1 - Rotating camera around ACharacter in C++, TopDown template

Newbie here, how do I update the camera to move and rotate around the character?? The camera and the spring arm is built in the ACharacter class, but i have no idea how to access the transform of the camera. I have a Controller class where all my inputs are being handled. Any suggestions or help?? THANKS!

note: This is a capstone I’m working on and they recommend me to code almost everything to pass so I’m trying to avoid blueprints if necessary.

is the camera and boom stored within the character or controller class?

if it’s in the character, then do this from the controller:

AMyCharacterClass* MyPawn = Cast<AMyCharacterClass>( this->GetPawn() );

you may need to create a function in your character class called GetCamera() that returns the camera if it’s private or protected.

Weirdest thing, I can access my character class in the Controller’s header file, but in the controller’s .cpp when I try to cast it, my character class can’t be found.

at the top of your controller cpp file, #include “MyCharacterClass.h”

Thanks! it worked :slight_smile:

Just a side note, the reason that you are able to ‘access’ your character’s class in the header file, is because you likely specified ‘class AMyCharacterClass*’ and not ‘AMyCharacterClass*’. The distinction is that you don’t need to have any prior knowledge to reference a ‘class AMyCharacterClass*’, because you are declaring that it will indeed exist and you plan to define it with the class keyword. That’s why you didn’t have to (and should never) specify '#include MyCharacterClass.h" in the top of your controller’s Controller.h file.

Quick Tech:
The reason this works is because you never need to access functionality of AMyCharacterClass in the Controller.h file. The only time you’re going to use its method definitions and fields is in a .cpp file, which is why you would include the actual AMyCharacterClass.h file in the .cpp file only. It’s then up to the compiler to properly link ‘class AMyCharacterClass’ to the corresponding object file that contains AMyCharacterClass’s method definitions.