Can anyone tell me the proper way to do this (purely in c++)?
Currently, I spawn a camera actor during my game modes begin play and set the player controller class’ target view to the actor camera. I’m not having any luck…
Can anyone tell me the proper way to do this (purely in c++)?
Currently, I spawn a camera actor during my game modes begin play and set the player controller class’ target view to the actor camera. I’m not having any luck…
Hi,
Try that
void MyPlayerController::TestCamera()
{
// Fast storage for camera (for example only)
static ACameraActor* pCamera = NULL;
if (!pCamera)
{
// Get current pawn camera
FMinimalViewInfo info;
GetPawn()->CalcCamera(0, info);
// Spawn camera
FTransform spawnTM(info.Rotation, info.Location);
pCamera = Cast<ACameraActor>(UGameplayStatics::BeginSpawningActorFromClass(this, ACameraActor::StaticClass(), spawnTM));
if (pCamera)
{
UGameplayStatics::FinishSpawningActor(pCamera, spawnTM);
}
}
else
{
// Teleport camera
FViewTargetTransitionParams params;
params.BlendTime = 1; // I want not make smooth camera changing (interpolation)
PlayerCameraManager->SetViewTarget(pCamera, params);
}
}
In addition, if you set up camera during game mode begin play, Player Controller may take possession over Camera after that. To avoid this – set up this variable to Player Controller: bAutoManageActiveCameraTarget = false;
Hope it helps!