Get the reference of a camera actor that I have placed in a level in the Player Controller BeginPlay

Hi!

How can I get the reference of a camera actor that I have placed in a level in the Player Controller event graph?

Maybe I can spawn the Camera Actor in the Player Controller instead of placing it in the level manually.

Thanks!

Hey @ViaCognita how are you?

The best way to do this is to assign an Actor Tag to the camera and then get all the actors with that tag in your Player Controller event graph.

To assign the tag to the camera, place it on your level, then click on it and go to the details panel. Once there, scroll down until you find “Actor” section, open the advanced options and add a tag (it could be “MainCamera” or something unique like that).

Then, in your Player Controler blueprint, you can use the following nodes to get that camera:

An that’s it, you can now manipulate that camera from your Player Controler blueprint.

Hope this helps!

1 Like

since the actor is already in the editor, a more optimal way is to have a soft object reference.

then you can select the correct actor.

when accessing the variable you check if it’s valid too.

shows like this.

alternatively, if you are going to use getactors, use the “get actors of class” then filter the tag manually. it’ll be faster than getting all actors with tags.

1 Like

To show another options to do it, I did it this way:

Or can also be done:

And setting the tag in the Camera Actor:

Btw, another tip:

you can create your own child of CameraManager and set it in the player controller (i think).

There you can keep references to your cameras, apply custom animations, and logic.

1 Like