Loop speed problems

My input is in Update. My usage of input is in FixedUpdate.

With an FPS of over 300, I have to slam my spacebar repeatedly to jump once.

And no, putting the input method into FixedUpdate doesn’t help.

private function checkControlVariables ()
{
	// Keyboard Variables
	keypressMovement = Vector3( Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical") );
	keydownJump = Input.GetButtonDown( "Jump" );
	keypressJump = Input.GetButton( "Jump" );
	keypressShift = Input.GetButton( "Sprint" );
	keyreleaseShift = Input.GetButtonUp( "Sprint" );
}

Anyone get this problem too?

Putting Input.GetButtonDown in FixedUpdate is a bad idea anyway, because it can easily happen that the frame where GetButtonDown happened is not the frame executing in FixedUpdate, resulting in missed input. Sounds like you have logic which is basically doing this, so it’s “falling through the FixedUpdate cracks”.

–Eric

So let me get this straight: I have first check the input, in FixedUpdate tell Update that the input has been read, and in Update if the input has been read, read new input.

I don’t like it, but it’s easy and it works.

Well…I would question why you’re doing that stuff in FixedUpdate in the first place; seems like you should just use Update.

–Eric

Like Eric, I’m not quite understanding why you want to poll for input in fixedupdate().

As it runs multiple times per frame, you’re polling date at a higher resolution that you’re responding to it.

Actually FixedUpdate doesn’t (usually) run multiple times per frame; it depends on what the frequency is. If you stick with the standard 60fps for FixedUpdate and your game is running 300fps, then you normally have FixedUpdate running once every 5 frames. So you only have a 20% chance of Input.GetButtonDown actually responding if you’re polling in FixedUpdate in this particular case. Hence the “slam my spacebar repeatedly to jump once” effect. :wink:

In low-fps situations, FixedUpdate can run multiple times per frame in order to maintain the desired frequency.

–Eric