I'm trying to create a Flying bird and when you stop pressing up arrow you lose height when you start pressing again up arrow you return to your original height.

How can i do that?
this is my code:

void FixedUpdate (){ 
if (isFlying && Input.GetKey (KeyCode.UpArrow)) {
 rigidbody.position.y = 1.0f; birdRB.MovePosition (bird.transform.position + (new Vector3 (0.0f, 0.0f, -move) Time.deltaTime)); 
} else { 
isFlying = false; birdRB.MovePosition (bird.transform.position += (new Vector3 (0.0f, -0.01f, -move) Time.deltaTime)); } 
isFlying = true; 
}

So, first, you should format your code properly so it’s clear and readable. This is how it ought to look to make debugging easier:

void FixedUpdate ()
{ 
    if (isFlying && Input.GetKey (KeyCode.UpArrow)) 
    {
        rigidbody.position.y = 1.0f; 
        birdRB.MovePosition (bird.transform.position + (new Vector3 (0.0f, 0.0f, -move) Time.deltaTime)); 

    } 
    else 
    { 
        isFlying = false; 
        birdRB.MovePosition (bird.transform.position += (new Vector3 (0.0f, -0.01f, -move) Time.deltaTime)); 
    } 
    isFlying = true; 
}

Note how each code block is easily visible and each line is on it’s own line.

Now that it’s easy to read, let’s take a look at what your algorithm is actually doing.

So, if the bird is flying and the up arrow is pressed, you attempt to set the position, then move it forward along the scene, correct? Two notes there: first, you’re using two different rigidbody references (rigidbody and birdRB). Is that correct, or should you be using one? Second is that Vector3s are structs, so when they are class variables, you should not set a single element, but rather the whole structure, like so:

rigidbody.position = new Vector3(rigidbody.position.x, 1.0f, rigidbody.position.z);

Next, if it’s not flying OR if the up arrow is not pressed, it will not be flying, but will continue forward and start falling. However, isFlying is always set to true at the end of the function for some reason. I’m almost thinking you should remove the boolean isFlying completely at this point because it doesn’t serve much purpose here.

The next thing I notice is that rather than simply adding the current position with “+”, you are using “+=”. Since that is in itself inside of a set position function, it will likely cause problems. You probably want to just use a regular “+”.

Lastly, rigidbodies are for using physics and force, neither of which you’re using with the manual moving of the position. Why are you using a rigidbody then? If you don’t need it, don’t include it.

Try looking into all that, and if you have further questions or problems, post a comment here and I’ll try to help.