How to make the camera follow my rag doll character?

I created my project using the “Code Side Scroller” template so that I have a blueprint character with a “CameraBoom” attached. The camera now looks at my character pawn capsule.

Now, I turn on ragdoll of my character with these 2 lines of code:

Mesh->SetSimulatePhysics(true);
Mesh->WakeAllRigidBodies();

Is there a way for me to, with code, make the camera look at the character mesh instead of the capsule? It looks like I can do it by calling CameraBoom’s AttachTo function, but what should I use as the first parameter as it should be of type USceneComponent*? Thank you.

When you ragdoll your character, the actor stays still and as you see the camera is following the actor not the mesh. Here’s my solution, if you’re character is dead, have the tick event update the actor to follow the ragdoll. Warping the actor like this will ignore physics collisions.

Furroy, thank you for your reply. I was actually looking for a way to do it in C++ code instead of Blueprint.

I found out how a while back and in case someone needs to know:
Attach the cameraboom(USpringArmComponent*) to the scene component instead of root component by calling CameraBoom->AttachTo(GetMesh()) within the ACharacter class

Thanks again for Furroy’s reply.

1 Like

Oh well thanks for your response that would be a more efficient way of handling it. I’ll try that in BPs later today.