Hi All
I’ve got a switch from default pawn to the player possessing a character, that’s giving me trouble. When the character is possessed, the camera position is initially at waist height, and updates to the correct position when you move the camera. In the constructor of the character I’ve got;
bFindCameraComponentWhenViewTarget = true;
I’m trying to use the playercameramanager to get it to update faster, so far I’m not really understanding what it’s doing, because its not working. This code is in the character class;
void ARRDevelopCharacter::OnBeginOverlap(AActor* Other, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) {
GEngine->AddOnScreenDebugMessage(0, 2.0f, FColor::White, TEXT("Begin Overlap"));
APawn* Test = UGameplayStatics::GetPlayerPawn(OtherComp, 0);
if (Other == Test) {
GEngine->AddOnScreenDebugMessage(3, 2.0f, FColor::Blue, TEXT("Actor is Player Pawn"));
AController* PlayerController = UGameplayStatics::GetPlayerController(Test, 0);
APlayerCameraManager* PlayerCameraManager = UGameplayStatics::GetPlayerCameraManager(Test, 0);
float DeltaTime = UGameplayStatics::GetWorldDeltaSeconds(this);
PlayerController->Possess(this);
PlayerCameraManager->SetViewTarget(this);
PlayerCameraManager->UpdateCamera(DeltaTime);
Test->Destroy();
}
How to update the camera position at the moment the character is possessed???
Many thanks!