Possess a pawn and use static camera?

In UE4 pawn possessing and view targeting are 2 separate mechanisms, but by default for easiness, player controller set possessed pawn as view target in same time. You can disable that by setting this variable in PlayerController to false:

This variable is also binded in blueprints and you can set it there too. After that you posses and set camera sepretly, you set view target using this function (which is also in blueprint)

Now here C++ exclusive feature, view target is a actor which camera manager asks about camera position (“From what position you want to be viewed?”) by calling ClacCamera function:

Default code in AActor class picks position of first active camera component in actor (so in blueprints you can control camera by activating and disableing camera components), you can change this behavior (and don’t use camera components at all) by overriding this function in actor that you gonna set as view target.

Hello, I am attempting to do two things:

  1. Control a Pawn that can fly around, and
  2. Look through a camera not associated with that pawn (static camera).

I’ve looked all over, couldn’t find anything, I know there are other questions like this one, please help, etc. etc… I think it’s because I’m using C++. My problems are:

  1. The pawn in question won’t possess the moment I hit the “play” button, even though it is set to “Default Player Start.”

  2. When I click “possess” I can control the pawn, but the viewport shows it as if it was a first-person view from the pawn, NOT the static camera.

What am I missing? And how, if possible, do I change it with C++?

In which file(s) would I write this code?

I mean, where do I write the code? Which specific .h or .cpp files?

What do you mean? You mean CameraCalc, you can override it in any actor class

Huh? Do you know basics of C++? first 2 links are variable and function in PlayerController, so you can call them anywhere you can access PlayerController, the last one is a virtual AActor function which you can override to change behavior of the actor, this function is called by camera system to asking how camera should be positioned.

I didn’t notice your auto possessing issue, i assume you set default pawn? you don’t need to do it in C++, just set in project serrings. If you don’t set default pawn and you just place pawn manually in editor then you code need to possess that pawn.