Download

Get Camera info from Camera Actor

Hi all,

I’m looking for a way to get the the aspect ratio of the camera to drive a screen-wrapping macro. To make it easy on myself, I’ve set my FOV for 90, and my distance (camera pointing downward in Z) is 5000. this makes my on-screen objects the proper size for the game. This means I set my screen wrap distance in X to be 2500, and my Y distance to be 2500 * 1.77778, given a 1920x1080 viewport. My objects go offscreen on one side and reappear on the other just fine.

I’d like to make this a little, or a lot, more elegant. I’m a VFX refugee, so calculating apertures and such is no big deal, but what I’m trying to do is calculate the horizontal screen wrap distance from the aspect ratio, which is determined by the X and Y of the viewport.

Currently in the HUD I have a 2D Vector variable called VPXY that I want to set with the viewport’s x and y size, from which I can derive the aspect ratio. What I can’t figure out how to get to is the scene camera FOV and distance. How I do i get camera transform and FOV from within:

-The HUD Blueprint?
-An actor Blueprint?

Thanks in advance, and thanks for all the information I’ve gotten from other threads so far!

-John

Hmm, I am not sure about your problem but the camera has variables for that. From the camea type in “aspect” for example

camera.png

If you need that info in another actor blueprint, take a look into the tutorial about blueprint communication. Inside the Blueprint you need the info create a Camera object and make it public. You can now assign your BP Object with the camera within or just a raw camera to that exposed Object and use it within your Second Blueprint.

HUD might be another case. I am struggeling myself to get the viewport size into the Player Controller because I need it for Clamping XY Movement so you cant move out of the camera but I cant get the it working because the PlayerController can’t have Objects exposed. This might also be true for HUD…I am not sure about that.

I found a partial solution: In the level BP, I can get the viewport XY and set variables in the HUD using a GetPlayerController->GetHUD->CastTo[MyHUD, the name of my HUD BP]. Then I can reference the HUD variables from various other blueprint objects. I can also use those to set the scene camera vars, as you suggested.

I wish there was a nice picture/graph of how the level BP, Game Mode, HUD, player controllers, and pawns all work, orders of execution, etc. If I ever figure it out, I’ll give it a shot.