x

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.

EDIT:
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:

CameraActor.Header

 UCLASS()
 class PONG_API APongCameraActor : public AActor
 {
     GENERATED_BODY()
 
 
 public:
     APongCameraActor(const FObjectInitializer& ObjectInitializer);
 
     //Camera Component
     UPROPERTY()
     class UCameraComponent *pongCamComponent;
 
 };

CameraActor.Source

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

PlayerController.Source

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


Thanks for your time and help!

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

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


smh

Product Version: Not Selected
Tags:
more ▼

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

avatar image

blueshifted
176 12 16 188

(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.

Cheers

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);
                 return;
             }
         }
     }
  
     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

Shadowriver
33.9k 916 164 1093

(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