Download

How to get current ACameraActor?

Is there a way to get the current ACameraActor, if several cameras are defined? I can get the location and rotation of the camera through the player controller, but getting an actual pointer to the ACameraActor for the current view eludes me.

Alternatively, how does one find a specific ACameraActor? Something like this doesn’t work for me:



ACameraActor* mainCamera = FindObject<ACameraActor>(GetWorld(),TEXT("MainCamera"));


EDIT: for the other object I tried a bunch of stuff, this, the player controller, etc., and I get NULL.

Gah, nvm, found it. Why does this always happen right after I post? :stuck_out_tongue:



	APlayerController* pc = GetOwningPlayerController();
	AActor *vt = pc->GetViewTarget();
        ACameraActor* camera = Cast<ACameraActor>(vt);
	if (camera) {
            //do stuff
         }