calling Level blueprint function from PlayerController blueprint

Hi all,

I created a function in Level blueprint which changes the camera. Now i’d like to call this function from my PlayerController blueprint with a key input event. But as i read, i can’t cast Level blueprint inside my PlayerController blueprint, so how to do so please ?

I know of 2 ways to call custom blueprint function on a level blueprint. If you can’t avoid it, that is. Ideally I keep most of my logic out of the level blueprint but I understand this isn’t always ideal. The more “complicated” way is to use event dispatchers. The easy way is to call the custom event using the Execute console command node.

In the command put this “ce YourCustomBlueprintNodeName” and that should work. You can call custom blueprint functions in the level blueprint by simply executing “ce NodeName” from the console. (ce I assume stands for custom event). It’s a handy feature.

Thanks, which is the best in term of performance ?

There is no difference, both ways are fast.

Also about your setup, you should reconsider making that camera function into separate blueprint. Then placing that blueprint as actor in level. This way you can reuse same code in different maps and parts of map (with different settings). Also communication with actor blueprint is easier than with level BP.

PS. I cannot think about situation that requires code in level blueprint, everything that i can think of can be solved by making blueprint actor or creating blueprintable component (then adding it to actor in level)

Hi Nawrot,

The issue is that camera actors referencers can’t be dragged from world outliner to any blueprint except the level one.

Another option would be to “get all actors of class” to grab your camera actors in another blueprint.

Ok, good news, so i have been trying to cast to my ScreenShotCamera blueprint from PlayerController blueprint for some times and i failed to choose a parent class.

Which node should i choose please ?

PS : The idea behind all this is to change camera when there is enough cubes landed in my tetris game area, in order to screenshoot from a nice camera angle to update my main menu background image.


The cubes colors are not good anymore, that’s why i’m trying to update this image. Furthermore, i wanna get rid of this gizmoand the highlighted cube.