Problem with getting KeyDown in fixedUpdate........

Hi!
I sort of understand why this code is not working, because keydown etc is based on framerate.
But my real question is how would i check for keydown in update and call rb.addfore() in fixedupdate.

AddForce is a physic movement and thats why i would like to use it in fixedUpdate!? Would it work or would there be some glitch!?

Code:

Blockquote

void FixedUpdate ()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        rb.AddForce(Vector3.up * jumpMultiplier);
    }     
}

Blockquote

Thanks!

use a Boolean variable in Update and check for it in the FixedUpdate method. FixedUpdate is invoked per physics tick/timing. Update runs per frame so.

private bool jump = false;  // just an example

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
        jump = true;
}

void FixedUpdate()
{
    if (jump)
    {
        rb.AddForce(Vector3.up * jumpMultiplier;
        jump = false;
    }
}

Thanks, how do i change to answerd