I think what you are trying to do is :
When you receive input from the player(Depends on what platform you are targeting )
the bird goes up Then the bird goes down (Like
flappybird )
The mistake you did that You are calling this code in update which will only
result in the bird going up forever.
you need to addforce for the bird so keep moving forward (You can do that in the update method) then when you get input from the player you addforce.up because the bird is going up
here is the code :
public class Bird : MonoBehaviour
{
private Rigidbody2D birdRB; // Pro Tip :try to not make
// your fields public do it only when needed , you can initialize
// the rigidbody in the start function
private float jumpForce = 2;
void Start()
{
birdRB = GetComponent<Rigidbody2D>();
}
void Update()
{
birdRB.AddForce(Vector2.right);
if (Input.GetKeyDown(KeyCode.Space)) // this depends on the platform
{
birdRB.AddForce(Vector2.up * jumpForce);
}
}
}
also I suggest adding a 2D CinmaMachine that follows the bird to further improve your project .