Locking 'Current Camera Z- axes'

I am making a 2d side scroller game.When my character moves up ,the camera goes up, and when my character dies ,I make it go under the ground and the camera also follows the character .However ,I want my camera to stay at the position where my character dies and let my character goes out of the camera.( like Super Mario)How can I accomplish that?

this sounds fairly straightforward… how are you controlling your camera (Spring Arm, Set World Location…) ?

I think I am controlling it with spring arm.

I understand…

I’ve need to do a very similar thing… so if you are using a Spring Arm Component, I’d suggest the following as the option that I use (having done a months of work with UE4 spring arms and cameras).

Use a spring arm component as usual — on your Player Character BP – but in the place of a camera, use an Arrow or Scene Component
Use a separate camera BP – your FreeCam BP — on TIck in its BP, use Set World Location and Set World Rotation to the location of the Arrow/Scene component. (if you’d like to be very efficient, use Set World Transform)

When Mario dies, just Branch away from Set World Location/Rotation/Transform in your camera BP… the camera will stay where it is and point where it was last pointing. When you resurrect Mario, just Branch back to Set World Location/Rotation/Transform… you can interpolate using Vinterp, Rinterp and Tinterp to smooth movement/rotation

At the Begin Play, in your character… Use Set View Target with Blend to ensure that your are using your FreeCam BP (UE4 might just add an additional camera to your spring arm or to your level by itself… it just does it)

Hi, in my recent side scroller game, i have 2 solutions

  1. Detach Main Camera at the moment of player die, simple if you don’t need complication.
  2. I don’t add any camera on actor, i’m making 1 Actor with camera and spring arm attach to it, and this Actor will follow Main Character location, this way i can add extra code to clamp Z value in my desire. So when fall through hole or jump too high the camera won’t expose what we don’t want player to see. You can even add some box trigger to modify that limit for each area.

In case of my project, each area have its own camera and trigger to handle camera limitation. I use SetViewTargetWithBlend to handle transition.

Can you attach a screenshot of your first solution? It seems easy but I still can’t figure it out . BTW I am using 2D side scroller template and I have SideViewCameraComponent under Camera Boom

i don’t have that first one anymore, my project is all in c++. So i make some little demo here with 2d side scroller project.

  1. Add box trigger

228456-1.png

  1. Add damage when player hit that trigger

228457-2.png

  1. Detach Camera when death

Um…I followed your instruction but the camera didn’t stay at the position where the character died ,it moved to other location,still thanks for the help.