Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How is the initial Location of PlayerCameraManager set?

I try to find the code snippet in which the initial PlayerCameraLocation is set. I had a look in the ShooterExample but I can't find anything.

alt text

As you can see in this screenshot, the CamerManager has a specified location in order to position the camera for a first person view. The CameraActor itself seems to be a child of it since it has no given location.

alt text

Here is the code of my own "InferiorPlayerCameraManager" which inherits from PlayerCameraManager:

 AInferiorPlayerCameraManager::AInferiorPlayerCameraManager(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
     NormalFOV = 90.0f;
     TargetingFOV = 60.0f;
     ViewPitchMin = -87.0f;
     ViewPitchMax = 87.0f;
     bAlwaysApplyModifiers = true;
 void AInferiorPlayerCameraManager::UpdateCamera(float DeltaTime)
     APlayerCharacter* MyPawn = PCOwner ? Cast<APlayerCharacter>(PCOwner->GetPawn()) : NULL;
     if (MyPawn && MyPawn->IsFirstPerson())
         //const float TargetFOV = MyPawn->IsTargeting() ? TargetingFOV : NormalFOV;
         const float TargetFOV = NormalFOV;
         DefaultFOV = FMath::FInterpTo(DefaultFOV, TargetFOV, DeltaTime, 20.0f);
     if (MyPawn && MyPawn->IsFirstPerson())
         MyPawn->OnCameraUpdate(GetCameraLocation(), GetCameraRotation());

It is pretty much the same as in the ShooterExample. This method "ticks" and calls "OnCameraUpdate" in the PlayerCharater.cpp:

 void APlayerCharacter::OnCameraUpdate(const FVector& CameraLocation, const FRotator& CameraRotation)
     USkeletalMeshComponent* DefMesh1P = Cast<USkeletalMeshComponent>(GetClass()->GetDefaultSubobjectByName(TEXT("PawnMesh1P")));
     UE_LOG(LogTemp, Warning, TEXT("CameraLocation: %s, CameraRotation: %s"), *CameraLocation.ToString(), *CameraRotation.ToString());
     const FRotator RelativeRotation = bViewFlag ? DefMesh1P->RelativeRotation : GetMesh()->RelativeRotation;
     const FVector RelativeLocation = bViewFlag ? DefMesh1P->RelativeLocation : GetMesh()->RelativeLocation;
     UE_LOG(LogTemp, Warning, TEXT("RelativeLocation: %s, RelativeRotation: %s"), *RelativeLocation.ToString(), *RelativeRotation.ToString());
     const FMatrix DefMeshLS = FRotationTranslationMatrix(RelativeRotation, RelativeLocation);
     const FMatrix LocalToWorld = ActorToWorld().ToMatrixWithScale();
     // Mesh rotating code expect uniform scale in LocalToWorld matrix
     UE_LOG(LogTemp, Warning, TEXT("CameraPitch: %f, CameraYaw: %f"), CameraRotation.Pitch, CameraRotation.Yaw);
     const FRotator RotCameraPitch(CameraRotation.Pitch, 0.0f, 0.0f);
     const FRotator RotCameraYaw(0.0f, CameraRotation.Yaw, 0.0f);
     const FMatrix LeveledCameraLS = FRotationTranslationMatrix(RotCameraYaw, CameraLocation) * LocalToWorld.Inverse();
     const FMatrix PitchedCameraLS = FRotationMatrix(RotCameraPitch) * LeveledCameraLS;
     const FMatrix MeshRelativeToCamera = DefMeshLS * LeveledCameraLS.Inverse();
     const FMatrix PitchedMesh = MeshRelativeToCamera * PitchedCameraLS;
     Mesh1P->SetRelativeLocationAndRotation(PitchedMesh.GetOrigin(), PitchedMesh.Rotator());

So I can't see anything that set the location and therefore it has to be in the parent class of the CamerManager... but even in the PlayerCamerManager.cpp is nothing that seems to set the location. Any help is welcome!! PS: I need the information because I want to make a 3rd person view and therefore need to set the camera a little further away from the mesh.

Product Version: UE 4.20
clipboard02.jpg (23.6 kB)
clipboard01.jpg (63.6 kB)
more ▼

asked Oct 06 '18 at 01:39 PM in C++ Programming

avatar image

1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question