Camera and Character rotation

My aim is to get the character rotating left/righ when moving the cursor on the x axis, and the camera rotating up/down when moving the cursor on the y axis. I made the camera a child to my character and attached this code to the character.

var speed = 4.0;

function Update () {

    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);

    var hitdist = 10.0;

    //Character rotation

    var targetPoint = ray.GetPoint(hitdist);

    targetPoint.y = transform.position.y;

    var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);

    transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, speed * Time.deltaTime);

    //Camera rotation

    targetPoint = ray.GetPoint(hitdist);

    targetPoint.x = Camera.main.transform.localPosition.x;

    targetRotation = Quaternion.LookRotation(targetPoint - Camera.main.transform.position);

    Camera.main.transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, speed * Time.deltaTime);


At the moment the left/right rotation is working fine but the camera isn't rotating at all, and it's very fidgety for some reason. Would appreciate any tips.

It looks to me like you are creating a ray with the mouse position... is there any reason you didn't just use the mouse movement? It seems much simpler to just:

var moveSpeed:float = 10.0;

function Update(){

    var moveUP:float = Input.GetAxis("Mouse Y")* moveSpeed * Time.deltaTime;
    var moveSide:float = Input.GetAxis("Mouse X")* moveSpeed * Time.deltaTime;