Download

Changing Camera with UI Button

I am trying to use a UI Button to change cameras, but I can’t access the cameras in the level from the Widget Blueprint. Does anyone have an idea how to accomplish this?

You could create camera array variable inside Game Instance and add cameras to the array inside the level blueprint, that way you access them inside the widget blueprint from Game Instance.

It’s pretty easy, and a way described above is madness

Why can’t you access the cameras in the level from the Widget BP? You can always use “Get All Actors from Class” and get all Camera actors in the level. I’m not saying it’s the best way, but it’s possible.
Take a look a this quick example:

cameras.png

It will get all cameras in the level, randomly select one and use it.

I didn’t realize that was a possibility. (I’m still very new to UE) I’ll keep that in mind if my current solution causes problems. Currently, I’m using an event dispatcher to send the on clicked event to a different blueprint where I have all my camera switching logic.

Thanks!