How do i set target camera in my player (c++)

I have created a player that has 2 camera components (FirstPersonCameraComponent) and (ThirdPersonCameraComponent) i want to know how do i switch between these two cameras on a key press in c++
because its only using the (FirstPersonCameraComponent) by default and it has really been bothering me. i was wondering how to set the target camera within the FPSPlayer.cpp Thanks

You can override this:

or leave it be and and activate deactivate camera components

I would be it crashes when i activate / deactivate

you tried to activate 2nd camera first and then deactivating? also did you tried overriding that function?

yes it still crahses and no i dont know how

hmmmm then try overriding that function :slight_smile:

Could you show me how?

For example:


virtual void CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult) override;


void ASomeActorWithTwoCameras::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)

       If(bFirstPersonCam) FPPCameraComponent->GetCameraView(DeltaTime, OutResult);
       else  TPPCameraComponent->GetCameraView(DeltaTime, OutResult);