Ground detection (3D)

So my isGrounded check works but I want to make the groundDis variable change in relation to the ground. For example, if the ground you are standing on is 45 on the Y axis and the character is that high you can jump, but say you go up a hill and it is 57 on Y axis but you can’t jump, but I want it to be able to detect the hight of the terrain and change the groundDis variable in real time in relation to the terrain height. Wow this sounded waaaayyyy better in my head.

My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour {

public float GroundDis = 1f;
public float walkSpeed;
public float sprintSpeed;
public Rigidbody rb;
public float jHeight;


	void Start () {
		
		walkSpeed = 4f;
		sprintSpeed = 10f;
		 rb = GetComponent<Rigidbody>();
		
	}
	

	void Update () {
		
		//Walking
		transform.Translate (walkSpeed*Input.GetAxis("Horizontal")*Time.deltaTime,0f,walkSpeed*Input.GetAxis("Vertical")*Time.deltaTime);
	
		//Sprinting
		
		if (Input.GetKey(KeyCode.LeftShift))
			
		{
			walkSpeed = sprintSpeed;
		}
		else
		
		{
			walkSpeed = walkSpeed;
		}
		if (Input.GetKeyUp(KeyCode.LeftShift))
		{
			walkSpeed = 4f;
		}
		
	
		
	}
	
	void FixedUpdate()
	{
		
		
		
		//jumping
		if (Input.GetKeyDown(KeyCode.Space)&&isGrounded())
		{
			
			Vector3 jumpVelocity = new Vector3 (0,jHeight,0);
			rb.velocity = rb.velocity + jumpVelocity;
			
		}
	}
	
	bool isGrounded()
	
	{
		return Physics.Raycast(transform.position,Vector3.down,GroundDis);
		
	}
}

Three ways basically:

or

or you make a raycast downwards everytime the player attempts to jump.