Respawn system with custom camera

Hello, I am trying to make a respawn system for my own 2.5D side scroller. But I also have a custom camera setup. Now when my character dies, the camera will glitch into my character’s head. How do I fix this?

This is my custom camera:


That updates the camera every tick.

This is my third-person game mode:

This is my beginplay in my thirdperson character:

And this is the death event also inside thirdperson charchter:

Now when I die, my camera glitches to a spot like this:

Even tough It should look like:

Thanks in advance!

Looks like you keep spawning new cameras, but GetActorOfClass returns the first actor found in the world, so you’re updating the first camera (which has a dead target) and not the followed one.

Instead of spawning new cameras, you could reuse the existing one. When spawning BP Camera, store it into a variable. Before spawning it, check if the variable is valid. If it is already valid, don’t spawn it and simply update its Follow Target variable.

Also in event Destroyed (and wherever you use it), use the variable instead of GetActorOfClass.

Thanks for your response! Okay, and where in my code should I store the camera in a variable? Sorry I am new to UE.

Drag the output pin from SpawnActor node and use “promote to variable”.

So in my beginplay of thirdperson character. After SpawnActor BP_Camera I promote it to a variable? Also how do I simply update its follow target variable?

Hey I cant find where I should promote to variable. Could you be more clear where to do this please ? and also how to update the follow target Variable?

Don’t skip that 1 tick delay - camera will bug into character head.

On death/respawn don’t mess with camera. Just spawn new character and should work just fine :slight_smile:

1 Like