Keep camera stable whilst attached to head bone

I have a camera attached to my players head.

The problem is that I want the camera to be perfectly still and not wobble along with the players head (like halo 3).
I know that I could just have the camera not be socketed to the head, but then when the player looks down and the spine bends, the camera won’t follow.

How can I have the camera follow the head and be perfectly still at the same time?

Since it probably won’t matter if the camera following is a frame or few behind the socket, you could use a tick function to do it every frame, thereby avoiding the rotational component.


Alternatively, you could decide to only use parts of the sockets location relative to your camera, e.g. only inheriting the height, which would look somewhat like:

auto aPosition = Camera->RelativeLocation;
auto saPosition = Mesh->GetSocketTransform("HEAD", ERelativeTransformSpace::RTS_Actor).GetLocation();
Camera->SetRelativeLocation(FVector(aPosition.X, aPosition.Y, saPosition.Z));

Really, it depends on what you want by “perfectly still”, but default attachment code won’t let you be specific like above.

Camera->SetWorldLocation(Mesh->GetSocketLocation(“HEAD”)); The camera will still wobble with this code because the head wobbles therefore moving the head bone with it which will in turn move the camera. I basically want the head to do it’s animation but the camera to not wobble with the head moving around. The problem is that if I just position the camera without attaching to the head socket, then the camera will be left behind when the player looks down (bending the characters spine towards the ground).

Use the location of the head bone, but the rotation of the controller.
This can be done with some of the camera options (bUseControllerRotation???) or by skipping the use of a camera component and making a custom PlayerCameraManager.

Maybe I am not understanding, but did you read exactly what I want?

Having the camera on the head bone would cause it to move around with the head and not be perfectly still…

Might just be what I thought you meant by wobble vs. what you actually meant by wobble :slight_smile:

By making the camera follow the rotation of the controller, you will still have the vertical and horizontal movement, but it will remove all the pitch, yaw and roll changes caused by the animation.

If you want to completely remove movement, you will need to fake it, which is what Halo 3 and many other FPS games do.
e.g. first person view with special first person version of the body/legs shown if looking down.

The only other thing I can suggest trying is use something to dampen the movement in the Y/Z planes in relation to the cameras rotation.
Check out the spring component and bone spring controller.

If you haven’t already though, try using just the controller rotation.
Its all we do and no one seems to mind it.