Switch pawn and transfer rotation (specifically pitch)?

I have two pawns, one FirstPeronCharacter and one based on the rolling example. What I’d like to do is be able to switch between the two, and use the rotation of the old pawn in the new pawn.

I have everything working except transferring the pitch when possessing the FirstPersonCharacter. Yaw works fine. I’ve tried setting the pitch of the character itself, which works, but has undesirable side effects. I’ve tried setting the pitch of the camera, which is what I’d expect to work, but the pitch gets reset to zero regardless of if I set the pitch before or after the possession.

If I set it to print the pitch of the camera every tick, I can see the correct pitch go by for maybe five ticks, but then it gets reset to zero. It’s not even long enough to notice.

I ended up getting this working by doing the following:

  • Get the world location and rotation of the old pawn
  • Set the world location of the capsule component
  • Set the relative pitch of the camera (clamped to (-89, 89))
  • Set the world yaw of the capsule component
  • Set the view pitch min/max to 89-pitch and (pitch+89) * -1, respectively

Those steps, in that order, are what worked for me. Since I’m setting the relative pitch of the camera, it’s necessary to adjust the pitch limits. We’ll see if this approach comes back to bite me later.