headbob in build too fast

Hey there!

I have a very strange problem, I am using the headbob script on a first person controller's camera found on the wiki(http://www.unifycommunity.com/wiki/index.php?title=Headbobber) and it works perfectly when I'm in the editor, but if I build and run it ,it goes super fast!

The only thing I can think of is if it runs off frame time and not true time, and where in the build it has better fps

any idea why this is happening?

Thanks!

1 Answer

1

It doesn't look like that code is framerate-independent. I only glanced over it, but you might try changing this:

timer = timer + bobbingSpeed;

To this:

timer += bobbingSpeed * Time.deltaTime;

And then readjust 'bobbingSpeed' as necessary. (Note that the change from + to += is unrelated to the timing issue.)