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"

Specify Actor for SetViewTarget() - How?

Hello, bear with me because this is a pretty basic question.

I placed a CameraActor with a CameraComponent (done via C++) in my level.
As soon as the game starts, I want every player to "see through" this camera.

I've changed my camera and it is now loaded with the level, not spawned during runtime. How's the syntax for the SetViewTarget() function if I wan't to set the view target of the playercontroller to this camera?
Here's my code:


 class PONG_API APongCameraActor : public AActor
     APongCameraActor(const FObjectInitializer& ObjectInitializer);
     //Camera Component
     class UCameraComponent *pongCamComponent;


 APongCameraActor::APongCameraActor(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
     pongCamComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("PongCameraComponent"));
     RootComponent = pongCamComponent;


 void APongPlayerController::BeginPlay()
     FString fInPC = "In PlayerController";
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, (fInPC));
     //SetViewTarget - How do I reference my CameraActor here?

Thanks for your time and help!

solved it, I simply set it directly as a variable.

 AActor *pongCam = GetWorld()->SpawnActor<APongCameraActor>(APongCameraActor::StaticClass());


Product Version: Not Selected
more ▼

asked Feb 07 '15 at 05:33 PM in C++ Programming

avatar image

176 12 17 190

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hey blueshifted-

It sounds like you were able to solve your issue by setting your camera actor as a variable. I am marking this post as resolved since it seems you are no longer having any problems with the reported issue. If you are still having any problems with setting up your cameras properly please feel free to reopen this post.


Doug Wilson

more ▼

answered Feb 13 '15 at 04:35 PM

(comments are locked)
10|2000 characters needed characters left

You simply set view target of player controller to specific actor. View target (which is actor) will will run CalcCamera function on every frame which modifies player camera position, by default (and ofcorse you can only change that in C++) it searches for last camera component in actor and set postion of player camera to it

 void AActor::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)
     if ([bFindCameraComponentWhenViewTarget](API\Runtime\Engine\GameFramework\AActor\bFindCameraComponentWhenViewTarg-))
         // Look for the first active camera component and use that for the view
         TArray<UCameraComponent*> Cameras;
         GetComponents<UCameraComponent>(/*out*/ Cameras);
         for (UCameraComponent* CameraComponent : Cameras)
             if (CameraComponent->bIsActive)
                 CameraComponent->GetCameraView(DeltaTime, OutResult);
     GetActorEyesViewPoint(OutResult.Location, OutResult.[Rotation](API\Runtime\Engine\Camera\FMinimalViewInfo\Rotation));

So to change that behavior you need to overriding your function in your actor

But i think easier option for you is to place CameraActors and assign each player to single one and set them as view targets for each

more ▼

answered Feb 08 '15 at 02:58 AM

avatar image

35.2k 921 166 1098

(comments are locked)
10|2000 characters needed characters left
Your answer
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