Q:How to make a UI Widget/UMG Button switch view target from one camera to another?

I am making a game with blueprints and I am want to make it switch to different cameras when I click buttons on my widgets. When the game starts a widget appears on the screen, I click a button on it, it is replaced with another widget then when i click a button on the second widget It should be changing the view target to the next camera but I don’t know how to make it work. I can’t create a reference to the camera actor in the widget event graph. So this is what I have in the widget blueprint event graph:


It replaces the second widget with another one but I wanna make it change to the next camera as well.
I tried copying the OnClicked(Button_1060), which is the button on the second widget to change
the widget to the third one and switch to the second camera, to the Level Blueprint like this: . I tried putting the previous camera instead of ‘Get Player Controller’ but it won’t let me to connect it to ‘Target’. So when I run the game and click the button it changes the widgets but the camera stands the same. Please tell me what am I doing wrong! I also tried to copy this: from the Level Blueprint to the Widget Event Graph and I got this: I’ve been using unreal engine for a few weeks.

I know the thread is super old but people often stumble across this, so incase anyone is having a similar issue and cant find an answer -

The reason “Camera_Hood,Engine” is becoming “Unknown” is because you’re taking it from the Level Blueprint (which can reference items from the level) to the Widget Blueprint (Cannot reference items from the level). Thats why it becomes unknown.

If you want to reference that specific camera:

  • Create a new “Camera Actor Reference” variable in your game mode. Name it anything you want. Compile/Save - Close.
    GMBP_Var.jpg

  • Open the Level Blueprint.

  • Make the Following:

3a62f91d66781c3e795bb5dabb1731f4a3802568.jpeg

  • To get the"CameraActor" node as above, simply grab the camera reference in your ‘World Outliner’ tab and drag it onto the blueprint.

Now if you want to get this camera reference in any widget,
simply make the ‘Cast To GameMode’ node and you should have access to that Camera Reference.

33d5f381d85df474324b96d43964bb46147725a4.jpeg

Hope this helps anyone still searching around!

Thanks for answering this!

This is exactly what I need but the jpegs with the graphs are broken?! :pensive: