APlayerCameraManager BreakPoint

I’m really curious why this is causing a breakpoint. Maybe someone can shed some light on the subject or tell me what i’m doing wrong, thanks.

void AMyCharacter::BeginPlay() 
{

	APlayerCameraManager* FOV = Cast<APlayerCameraManager>(this);
	FOV->SetFOV(15.0);

    // ...

}

You seem to be trying to cast AMyCharacter rather than it’s camera manager to APlayerCameraManager.

You may have to grab the controller first and then get it’s CameraManager (switch out the class names for yours)

AShooterPlayerController* MyPC = Cast<AShooterPlayerController>(Controller);
auto CameraManager = MyPC->PlayerCameraManager;
CameraManager->SetFOV(15.0f);

I’m still new to UE4 so that may be completely wrong. Also, it may be more appropriate to put that code in the CameraManager itself.

Ha, well thanks for the effort. But when casting it’s the only way to use methods from other classes.

Definitely very new, Camron but that’s alright. :D.

Essentially APlayerCameraManager* FOV is creating a pointer to the class since the idea is to be able to use those methods from a custom class.

GEngine->GetFirstLocalPlayerController(GetWorld())->PlayerCameraManager->SetViewTarget(this);

Why does this work as opposed to what my code above?

I think you are trying to cast the wrong thing. You are trying to cast a character to a CameraManager. I think you may need to grab the controller and then the camera manager from it.

Well now I just feel like an idiot. Ha, it worked. Nicely done. You’re definitely right about the casting part. Well, I learned my lesson. Thanks a bunch. :slight_smile:

		APlayerController* MyPC = Cast<APlayerController>(Controller);
		auto CameraManager = MyPC->PlayerCameraManager;
		CameraManager->SetFOV(15.0f);