Multiplayer Shooter - Spectate another character after death and destroy

I want to build a system that when the character dies, the dead character can spectate another character that is still alive. Now I know that in the PlayerController class, there is a function called SetViewTargetWithBlend…This works well if I don’t destroy the character. However, I want to be able to destroy the character after the character dies.

So my question is, how can I accomplish the same thing as SetViewTargetWithBlend while destroying the dead character at the same time?

Try unpossessing the controlled character before changing viewtarget

Thanks for your reply. Unfortunately, this solution does not work. Camera does not follow another living player. It just stays at the point the character died.

Bumping this thread…

You need to create a spectator class. On death the server (game mode) spawns the spectator class and you possess it.

You then simply get a list of all simulated proxies on the client. Each will represent a living player. You can then either set view target with blend or simply attach your camera to the sim proxy of choice.

1 Like

Interesting, thanks for your response. So you’re basically saying to

  • unposess from the dead character
  • possess the spectator pawn
  • set view target from the spectator pawn to another character
  • destroy the dead character

There’s an already spectating system out there.