Moving a character's bones independently with code

Hi,

I’m making a third person game with an aim/shoot feature. When the player takes aim, the camera moves into an over-the-shoulder view.

The problem I’m having is when looking up or down in this view my character remains looking forward and I’d like it to look up/down with the camera. I can have the entire character model do it, but then the character is just floating in space, and looks silly. I only want to move the top half of the model so that the feet remain grounded.

I’ve tried using code to set the rotation of the skeleton’s spine to match that of the camera, but had no luck (the same code works with normal objects, just not the bones of the character).

Is there any way to force a bone to move independently through code? My project is in C#

Thanks for reading.

If you are playing animations then you need to apply your rotations in LateUpdate or they will be overwritten by the animation system.

@google thanks