Switching camera between multiple positions.

Hi, I’m trying to make a camera switch between different positions, but I’m a 3D artist and not really familiar with blueprints.

I want the camera to switch between 5 positions. It should move to the next position when you click the forward button on the UI and switch to the previous position when you click the backward button.

I created a blueprint called “BP_CamPos_1” that contains a red arrow to show the direction the camera is looking. I placed 5 instances of this blueprint in the scene. These are the positions the camera should switch to.

I managed to make the camera switch to position 1 when clicking the button, but I don’t know how to make it switch back and forth between the positions.


Well, there are several ways to accomplish this. I personally think the easiest way for you is to have 5 Cameras, and take one of them according to some variable or function.

I think this way is easiest (assuming five fixed positions) because then you can pilot each camera into place, and even adjust view angles and other lens features for each one.

So if you make a single camera switcher blueprint with variables:

With a few helper functions:

Reference the cameras in the outliner:

Now you can reference the camera switcher BP and just call Forwards or Backwards on button clicks.

NOW, I know you may not be doing things this way, but the LOGIC is the same - you have an array of positions (maybe you are just using an array of transforms, for example), but you need to keep track of which element you’re on, and then add or subtract one from the index into that array (the functions I have roll over, so going backwards from zero takes you to the last camera, and going forwards from the last takes you to the first).

2 Likes

Unfortunately, I need it to work with a single camera. It’s a kind of camera simulation where you can adjust the shutter speed, focal length, and aperture through the UI, and these settings need to remain consistent across all positions.

And the user doesn’t need to set the camera positions, they are still all just fixed?

In that case, just create an array of transforms instead of camera references, and apply the transform to the CineCameraActor. The logic is still the same.

Yes.

I want to make it even simpler and just let the player move forward to the next camera position. I’m trying to make it “on clicked” and cast it directly to the character.

But I dont know how to fill the array with the camera positions.

“Editing this value in a Class Default Object is not allowed”

Is this data is being replicated across multiple levels?

No, it’s just one scene with different camera positions and times of day settings.

Sounds good, if you need multiple cams you dont have to use the cinimatic cam you can always use the basic cam to swap between if you know how to do it, generaly from the set view target with blend would work.

No, I need the CineCamera because the user is supposed to use real camera settings like shutter speed, aperture, and ISO. It’s like a camera or photographer simulation.

You fill in those reference values in the outliner, not in the blueprint editor.

But I’m still not sure you’re approaching this the best way. Again, you can still have 5 CineCameraActors in your scene that you can “pilot” into place (if you haven’t seen this, you can right-click a camera that you’ve put in your level and select “pilot,” then you can fly around the editor to where you have a good view, then you can stop piloting and the camera stays where you’ve moved).

So now you have the five locations, but there is a single, specific camera you are allowing the user to manipulate through your UI, right? Is that a Cine Camera component of the Blueprint being manipulated by the UI?

Ok, so bear with me for a moment - you’d still have these cameras, but all you want from them is their transform, so we can use what I’ve given you above, but modify the “take” function:

So we’ve added the CineCamera component to this BP, and now we are ONLY viewing what this camera sees, but we are updating it’s transform using the transforms from the other cameras.

I mean, this is programming - there are a lot of ways to accomplish what you want, but I always tend to think simplest is best. Using a reference to cameras in the level is very straightforward, IMO, I do it all the time (I do virtual production for TV, including things like virtual camera flythroughs that land on a tracked camera).

Thank you for your patience. I’m trying it your way now. Hopefully, all the settings the user can adjust in the Widget Blueprint (shutter speed, ISO, focal length, aperture) will be transferred to the separate cameras.

But how do I create this purple node at the beginning? Should it be in the construction script of “BP_CamSwitch” rather than in the event graph? If so, I can’t find the “Get Player Controller” node with the “Player Index” input there, it only seems to be available in the event graph.

The nodes are purple because they are functions, not events. There’s apparently more than one Get Player Controller. It might be easier to work in reverse - create the Set View Target With Blend node first, then drag off the Target input.

EDIT: also try disabling “context sensitive” when you’re looking for the node, you should see more choices.

I didn’t know how to use functions, so I used this approach. I’m not quite sure why I need to validate the third-person character and player controller, but it works. This is in a separate blueprint BP_Camera_Switch.

Now, I need to connect the camera controls in the user interface widget with every single camera I switch to. But I have no idea how to do this. So far, I used the cinecamera in BP_ThirdPersonCharacter.


Do you have a good idea how to do this?

You don’t need to do that if you use the last technique I described above - those other cameras are just references, you’d only take their positions and apply that transform to the “one” camera you’re actually using.

The last version of the “take” function I showed above does that.

If you don’t even know how to write your own functions, though, it means you should probably at least do a few tutorials before trying to take on a project.

Now, I don’t know how to write a function, and I only need it for this single project.

You can create custom functions, events, variables in the BP editor (on the left, click on the +).

Now you can create a new variable named something like “Camera”, with type BP_CineCamera (your camera blueprint).

Create another variable named something like “Positions”, with type Transform.


Change it from “single” to array by clicking on the little orange dot (where the arrow points).

Now, create a new function (just like you did for a variable) and name it something like “SetPosition”:


Add an input by clicking on the + (where the arrow points), name it something like “Index” and set its type to Integer.

You can now create your function (it should open by default, but if it didn’t, you can double click the function name on the left).


To get your variables as nodes, drag and drop them, and select Get.

Now, to call your function, go back to your event graph (on the top), and implement this kind of logic

A few details:
Depending on if you chose a BP or a Widget ot create the switcher, you will need to setup the references differently:

  • BP: Place it in your world, and set the reference of the camera and the positions in the outliner.
  • Widget: Set the camera variable as “Instance Editable” and “Expose on spawn”, set the positions directly in the widget editor, and the camera reference when you create the widget.

Tell me if you better explanations on some parts

1 Like

This is getting interesting.

@JAuzanneau Thank you so much for this very detailed explanation.

Depending on if you chose a BP or a Widget ot create the switcher

I’m not sure about this point. So far, everything related to adjusting the camera settings (like shutter speed) is done in the Widget Blueprint. From here, I call the BP_ThirdPersonCharacter, which has a Cine Camera attached. This is the camera that needs to switch to different positions.

The Widget Blueprint also contains a call or reference to the BP_CameraSwitch blueprint, where I switched the camera like this:

Now, I have created a variable inside BP_CameraSwitch called MainCamera with the type BP_CineCamera_1, as you suggested. The blueprint BP_CineCamera_1 is in the scene, and it represents the first position that the Cine Camera inside BP_ThirdPersonCharacter should switch to.

But this can’t be right, since I’m using the position as the target. However, I can’t find the Cine Camera of the BP_ThirdPersonCharacter as an object type for the MainCamera variable.

In your last paragraph, you mention how you get the positions and camera references. I think you got a little confused when you added the variables.

Here is how I would go about it:

First, let’s take a look at the BP_ThirdPersonCharacter blueprint, it should look something like this: (in this case this is an actor BP, but the important part is that the Cine Camera is a component and not an actor like in my first reply)

Now, to access the camera inside the widget blueprint, create a new variable of type BP_ThirdPersonCharacter. Make sure to check Instance Editable and Expose On Spawn.

Now you can simply get the camera reference like so:

image

At this point, it is very close to my first reply, create a variable of type Transform, and make it an array. Compile the blueprint, then you can add default values at the bottom:


Simply add as many as you need. I added 3 in my example

After that, you can create a new function like before:


And you can call it like so (here Index is another variable of type Integer I added):

As for the rest of your parameters (like shutter speed, etc…), you just use the same reference and you’ll be good.

Just in case, this is how I spawn my test widget (one of many ways to do so):
In the BP_ThirdPersonCharacter event graph:

As before, tell me if you need more clarifications

1 Like

Hi @JAuzanneau,

Thank you very much for your time, this approach worked. There are just a few minor issues.

I’m not sure how to use “Set View Target with Blend” anymore. It now just switches to the next position in the transform array without blending between the positions.

If I slightly change the position of one of the Cine Camera Blueprints in the scene, I need to copy and paste its location and rotation into the transform array manually.

Would it be possible to read the transform directly from the Cine Camera Blueprints in the scene and move to their positions instead?