Download

Destroying pawn moves camera

I’m using ‘set view target with blend’ in my level’s ‘event begin play’, and connecting up a camera from the persistent level as well as the player controller with ‘get player controller’ set to 0. Pretty standard stuff it seems, works well until I destroy my pawn and the camera snaps to some default location.

I’m wondering what destroying the pawn has to do with the camera placement? I’m referencing the playerController (which has a camera) and the pawn doesn’t even have a camera.

I can fix it by destroying all components in my pawn instead of the pawn actor but I’d like to know why this is… I’m sure I’ve got some sort of wrong understanding of it all but can’t figure it out…

Thanks!

Had some more thoughts about it - I wonder if killing the pawn makes the engine reset that ‘set view target with blend’ as it might assume my pawn’s camera (again, which doesn’t exist at all) was used and snaps right back to the playerController camera, which is at origin it seems…

Sorry to unearth this ancient post, but it’s the only one that came up when I searched for a solution to this problem, and to save anyone else wasting their time looking for an explanation for this behaviour I’m replying to this post.

I’ve just encountered this problem in 4.24.

It’s due to the setting Auto Manage Active Camera Target in the Player Controller being set to true. This is also the setting that causes the player controller to find the player camera when the level starts as if it is set the pawn calls AutoManageActiveCameraTarget(GetPawn()) in OnPossess.

When OnUnPossess is called on the Player Controller, it calls SetPawn(NULL), which causes this little snippet to be run



if (bAutoManageActiveCameraTarget)
{
    AutoManageActiveCameraTarget(this);
}


Overriding whatever view target you’ve set. If you have a separate auto managed camera it will use that, otherwise it will use the Player Controller as the view target. In the above post this seems to be located at origin, while in my case it was located at the player pawn, but with a weird rotation, neither of which I wanted.

I fixed it by overriding the Player Controller and setting Auto Manage Active Camera Target to false, and from Event BeginPlay setting the view target to the controlled pawn. This retains automatically setting the view target to the player camera but removes the weird camera behaviour when the player pawn is destroyed.