Is it possible to add a second camera to the pawn/actor so I have a total of 2 camera’s in my third person game. One camera behind my character. The second camera to the side looking at my character. Then I would want to be able to switch between camera’s with the push of a button. I know this can be done by putting 2 camera’s in a scene and in the Level Blueprints you would switch between camera’s by pressing a letter like J. But can this be done by have the 2 camera’s in the characters Blueprint Class file, in the Viewport Tab, and how would I do this?
Yup, you can have as many as you want.
You’ll have 3 options here:
- Do not switch cameras
Rather than switching between cameras, change the position of the current camera by manipulating its relative offset
- set the camera’s relative location and rotation to instantly switch between the viewpoints
- or interpolate between the 2 locations either during tick or using a Timeline if a smooth transition is needed
- Use Child Actors + Set View Target with Blend
- in Blueprints, Set View Target with Blend cannot be directly forced to use a specific camera (unless something changed recently), this node selects the first active camera it finds. If you cannot afford to activate and deactivate cameras (let’s say you need a rear-view mirror in the car which needs to be active all the time), having cameras as Child Actors is a decent enough solution.
- Keep only 1 camera active and Set View Target with Blend
- Deactivate current camera component, activate the desired one and then Set View Target with Blend
- use FlipFlop node if there are only 2 cameras to operate
Thanks a lot! Very helpful!
How do you activate and deactivate a camera component?
Also is there anyway during PC possess to set priority for a particular camera? My pawn has 2 cameras but the PC is always possessing the undesirable one.
Also to confirm, Set View Target with Blend cannot set view target as a Camera Component, is that right?
Thanks!
Hi @qwerty9201888. Yes it can be done. Checkout the Prototype Blueprints from @TheGameDevStore. It uses a single camera that interpolates between ‘viewpoint’ arrows on springarms at the push of a ‘Tab’ Button. You can add more springarms / viewpoint pairs as needed. Sweet Code.
Technically, all you need is this:
One cam is autoactivated, the other one is not:
You can set it directly, too or query:
If you wish to cycle through any number of cameras in the same actor:
Also to confirm, Set View Target with Blend cannot set view target as a Camera Component, is that right?
That’s correct. You can do this, though:
The child actor does not even need a camera but it’s handy to give it one since cameras have fancy features. It’s crude but works surprisingly well.
If more precision / control is needed, you can interpolate using a Timeline; you wouldn’t even need multiple cameras for this. Store transforms for each viewing angle and transform a single camera between those points. Or use an arrow component to visualise it.