Hi, Im creating a simple enviroment for a college project. I have added this script unifycommunity.com to my character so its head will bob. After doing this I can no longer walk downstairs. What can I do to fix this?

Your problem is in this little bit:

```
transform.localPosition.y = midpoint + translateChange;
}
else {
transform.localPosition.y = midpoint;
```

Every single frame you are setting your y value to 2. This means that your transform will NEVER be able to fall, jump, or climb anything. You will always be at exactly y = 2.

Try this (edited from your script - mostly unchanged):

```
private var timer = 0.0; //used as the input to the sine function
private var translateChange = 0; //How far the camera is away from it's resting point
private var lastTranslateChange = 0; //used to keep track of the delta (change in) translation
var bobbingSpeed = 0.18; //How quickly the camera bobs up and down
var bobbingAmount = 0.2; //How high/low the camera's max/min bob is.
var settlingRate = 1; //determines how fast we return to 0 position while standing still
function Update () {
var waveslice = 0.0;
//determine how fast the player wants to move
var horizontal = Input.GetAxis("Horizontal");
var vertical = Input.GetAxis("Vertical");
//first, grab a sine value to work with
//not moving --> return to midpoint
if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0) {
timer = 0.0;
}
else {
//we are moving, grab a bob value from the sine curve
waveslice = Mathf.Sin(timer);
timer = timer + bobbingSpeed; //move along the sine curve for the next cycle
if (timer > Mathf.PI * 2) {
timer = timer - (Mathf.PI * 2); // sine repeats after 2PI. Keep timer in a reasonable range
}
}
//now calculate how much we want to move the camera
//we ARE moving
if(waveslice != 0)
{ //bob up and down based on a sine wave and movement amount
translateChange = waveslice * bobbingAmount; //scale translation by bobbing amount
totalAxes = Mathf.Abs(horizontal) + Mathf.Abs(vertical);
totalAxes = Mathf.Clamp (totalAxes, 0.0, 1.0);
translateChange = totalAxes * translateChange; //scale translation by movement amount
}
else
{ //we are sitting still, smoothly return to 0 position
translateChange = Mathf.Lerp(lastTranslateChange, 0, Time.deltaTime * settlingRate);
}
//now actually move the camera
//move the transform's y component by the delta translation
transform.localPosition.y += translateChange - lastTranslateChange;
lastTranslateChange = translateChange; //keep track of last cycle's translation
}
```

Edit: changed/added comments as requested

This is great! thank you very much!! Would you be kind enough to just add comments to each line so it’s easier to understand exactly what’s going on?

Thanks a lot!

This is great! thank you very much!! Would you be kind enough to just add comments to each line so it’s easier to understand exactly what’s going on?

Thanks a lot!

i’ve noticed that all the camera men wear a jacket that says BOB on the back…what does it mean? does it represent something?