Why the ball is not jumping in direction

Following a tutorial I was able to make a simple ball jump. However the ball jumps only on y direction and only when on the ground. My question is why the ball is not jumping when it’s moving or why doesn’t jump in the direction of movement (left or right). Here is how I coded:

using UnityEngine;
using System.Collections;

public class BallControl : MonoBehaviour {

// Use this for initialization
public float rotationSpeed = 100;
public float jumpHeight = 8;

private bool isFalling = false;
// Update is called once per frame
void Update () 
{
            //-----------Handle ball rotation 
    float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    GetComponent<Rigidbody>().AddRelativeTorque(Vector3.back * rotation);

    
    if(Input.GetKeyDown(KeyCode.Space) && isFalling == false)
    {
        GetComponent<Rigidbody>().velocity = new Vector3(0, jumpHeight, 0);
        
    }
    isFalling = true;
}

void OnCollisionStay()
{
    isFalling = false;
}
}

It only jumps when you are on the ground because of isFalling == false check on line 20, which is only true if you are currently in a collision with something (line 30).

It only jumps straight up because on line 22, you are setting the y velocity to jumpheight, but both the x and z components of velocity to 0: GetComponent<Rigidbody>().velocity = new Vector3(0, jumpHeight, 0);