Weird camera angle after destroying pawn

So I’ve run into a bit of a problem regarding character death and cameras. Just as a preface, I’m using Paper2D, if that helps.

The pawn I’m using is a modified version of the pawn/character (“My Character”) provided in the Paper2D template. When I call destroy, I’m led to believe that this also destroys all of the components inside of the Blueprint, including the camera and spring arm components. What ends up happening is the camera shifting out of orthographic into perspective and looking in the direction my character was walking/running in, location appearing unchanged until he ultimately respawns, at which point the camera either centers back on him or the camera switches to the one attached to him. My solution to the problem was to create a separate camera that follows the character around, and while it does that marvelously, I still have the same problem when the character gets destroyed.

Normal camera operation

Camera after Destroy is called on the character

So what can I do to change this? Setting rotation on the camera or the actor doesn’t appear to solve the situation, or at least not the methods I’ve used. Thanks for any help you can offer.

1 Like

I assume your camera is part of the pawn (which is normal) the thing however is that if you destroy it, it will destroy the camera as well and default to your controller camera.

Try instantly spawning a new one with the same location, etc as your normal one and using that one until you respawn. Our don’t destroy your actor but only remove the mesh and destroy it right before you possess the new one.

Cheers.

I figured as much that if the actor got destroyed all of the components inside got destroyed as well. Currently what I have going on is a camera that is completely detached from the pawn and is its own entity. Its position is getting modified based on the position of the pawn, assuming the pawn is valid. If it is not valid, it is to explicitly stay at the same transform.

I’ll go ahead and try your first suggestion to see if that works. I presume I just switch to it using Set View Target… with the new view target as the camera actor? Otherwise, your second suggestion will probably work for me though it will take a while to account for the actor still technically being present despite not being visible for enemies amongst other things. I’ll get back to you as soon as one of these are successful.

Alright that does confuse me a little. The setup you had should work in theory…

Could you show me the code you use to update the location of your camera? Maybe you did a mistake there.

Alright, I figured out the problem. Thanks to @Erasio for reminding me to check my camera update function as it led me to the solution.

The object turning my camera sideways at first appeared to be the PlayerCameraManager, as I noticed it’s rotation changed from -90 yaw to 180 yaw. Of course, as luck would have it, directly modifying the rotation of that didn’t do anything, so I took it a step up to the PlayerController, and modified the ControlRotation. This worked only for a split second, as I only called this in my respawn function and not every update/frame. I made the same call in my camera’s tick event, and the it worked like gangbusters. Side note for anyone who is trying to achieve something similar, make sure that you set control rotation in your respawn script in addition to the tick event, otherwise, you’ll have a few random frames looking at the weird angle again until the tick event is reached in your camera. Lastly, to avoid confusion in the pictures below, Piran is the name of the pawn the player controls.

Respawn functionality in the GameMode event graph

Camera Blueprint event graph

Find pawn function

1 Like

Thanks for being so detailed on your answer, I would have never even thought it was the player controller. What a total pain in the neck haha