Head bobbing?

Does anyone have a head bobbing script for an FPS, so that when the player walks along, there head moves up and down to simulate real walking.

I checked out the head bobbing script on the wiki but it doesnt appear to work, has anyone managed to implement it?

anyone?

Sadly nothing in this world is free.

Here you go,

You attach the “Joystick” Script that is in the Unity 3 Mobile Asset Folder. It takes the position of the joystick and adjust the head bobbing. So, the “faster” you walk the more the head bobs. I tweaked the head bobbing script from the wiki. I use the following values: “Bobbing Amount” = 0.05 and “Midpoint” = 1. Just attach this to your main Player’s camera.

var moveTouchPad : Joystick;
 private var timer = 0.0;
 var bobbingAmount = 0.2;
 var midpoint = 2.0;


 
 function Update () {
 	
 	
 	if (moveTouchPad.position.y > 0 || moveTouchPad.position.y < 0 || moveTouchPad.position.x > 0 || moveTouchPad.position.x < 0){
 		 
    waveslice = 0.0;
       if (Mathf.Abs(1) == 0  Mathf.Abs(1) == 0) {
       timer = 0.0;
    }
    else {
       waveslice = Mathf.Sin(timer);
       
       if (moveTouchPad.position.y > 0)
       timer = timer + (moveTouchPad.position.y * .4);
    
       
       if (moveTouchPad.position.y < 0)
       timer = timer + (-moveTouchPad.position.y * .3);
   
       if (moveTouchPad.position.x > 0)
       timer = timer + (moveTouchPad.position.x * .4);
    
      
       
       if (moveTouchPad.position.x < 0)
       timer = timer + (-moveTouchPad.position.x * .3);

       if (timer > Mathf.PI * 2) {
          timer = timer - (Mathf.PI * 2);
       }
    }
    if (waveslice != 0) {
       translateChange = waveslice * bobbingAmount;
       totalAxes = Mathf.Abs(1) + Mathf.Abs(1);
       totalAxes = Mathf.Clamp (totalAxes, 0.0, 1.0);
       translateChange = totalAxes * translateChange;
       transform.localPosition.y = midpoint + translateChange;
       if (translateChange <= (-0.05));
   
       
    }
    else {
       transform.localPosition.y = midpoint;
    }
 	}


 }

Anyone have feedback if Crazy Robot’s script works?

Crazy Robot’s script doesn’t work.
it is only for iphone games and ipad games
and the vars he wan’ts us to copy woon’t do anything

You have to attach the above script to the camera, then assign the joystick script to the “moveTouchPad” var. this is only for iphone/ipad.