Attaching camera to head bone

Hello.

I’m trying to attach my main camera to the head bone so that when the head is animated, so will the camera. Note that the camera also has a mouse look script for only the Y-axis (for looking up and down, left/right is handled in the player).

I’m also using the character in the Locomotion System

I’m a fan of using scripts and such so this is what I was using to attach it as a parent:

#pragma strict

var assignTo : Transform;

function Start(){
	transform.parent = assignTo;
}

This works but then the camera is facing the wrong way. Something’s wrong with the rotation. I’m sure there’s something I can do to fix the rotation but I am unsure on how to do that.

Here are some screenshots.

Main character/scene:
http://puu.sh/1uoNW

In game:
http://puu.sh/1uoVh

In scene (while running):
http://puu.sh/1uoWj

In scene (while running, head selected):
http://puu.sh/1uoXa

In scene (while running, camera selected):
http://puu.sh/1uoXo

I know it’s probably something small but I just can’t figure it out.

Thanks!

if your bone have the right orientation , then before parenting set your camera orientation to be same as your bone, and eventually you want do it while your character do not animate yet…just to avoid some slight offset in the process.

Alright I fixed the problem. Turns out it was due to me putting the MouseLook script (for y-axis) under the camera when I should have put it under the head. Also in order to enable to camera to move while the head was animating, I had to check “animate physics”