Switching Between Cameras attaching to a Blueprint

Hello, I’ve been working building a custom animation that is suppose to play in the scene whenever a player hits a specific button, however as part of this animation I need to have the players perspective switch to a series of cameras that are attached to the object that is animating. I’ve tried a few tutorials but so far none have gotten me exactly where I need to be.
I’ve attempted creating in the blueprint for the object a graph that on pressing E should allow me to swap between the cameras however once I test in level nothing happens when I press E.

I’ve also tried using a flip flop in the level blueprint which has had more success but I seem to be limited to only camera plus the player camera. But I don’t know if I’ll be able to get the animation blueprint which holds the cameras and the level blueprint properly talking to each other.

I’m a bit new to using blueprint so any help would be appreciated, thank you.

assuming that you have already been able to switch between 2 cameras.
would it be acceptable to instead of storing different cameras store a SceneComponent; then when you have the player go into the lookThroughCamera() you blink the camera to black, and then have a camera Attach to the the selected SceneComponent, and if you were to cycle between the “Cameras” it would just be blinking the camera to black, and doing another Attach.

if you don’t want to deal with detaching and reattaching the camera from the player character then you can do this with the second camera you are allowed.

the reason I suggest blinking the camera is that the player might find it more then a little jarring to have the camera suddenly be looking at something new, and it gives the players brain a moment to comprehend that something should have changed.

Was able to resolve it will some insight from a friend.
First I needed to create an array for the cameras then created two commands for cycling up and down. Key was creating an integer for tracking which camera was and then adding to or subtracting from each time the switch was hit.

Here is a picture of the cycle up command.

if you run up against memory limits, then your Array of cameras could become an Array of “Transforms” and my above comment would then be usable.

to condense the blocks a bit you can do something like this:

(the stuff in the grey comments is for explanation)
one of the reasons C++ has the name it does was because one of the most common lines of code was
number = number+1; so the creator added the “++” operator that makes that line simpler to write. and of course “–” (minus minus or “decrement” is very similar)

By using “magic numbers” you limit your implementation to that specific amount any more or any less and you will get “unintended” behavior (if someone using this script was to only add 2 camera to the array the game would crash when you CurrentCamera goes to 3), if you are going to be pulling from an array of “known size” then use the Length of that array as your bounds.

the Decrement has a little more going on: mainly because C++ allows if A%B=C where A<0 then C=[-B,0], so by adding the max value back we ensure the result is positive and in the bounds.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.