RaycastHit hit;
Vector3 direction = transform.TransformDirection(Vector3.down);
Ray ray = new Ray(transform.position, direction);
if(Physics.Raycast(ray, out hit, 3000, ground))
{
    distance = hit.distance;
    if(distance<2)
    {
         isonground = true;
    }
    else
    isonground = false;
}
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class mainEngine : MonoBehaviour
{
    public rotors mainblade;
    public rotors tailblade;
    private float enginepower;
    public float enginepw
    {
        get
        {
            return enginepower;
        }
        set
        {
              mainblade.bladespd = value * 250;
              tailblade.bladespd = value * 500;
              enginepower = value;
              //i don't know why he multiplied by 250 here?
          }
    }
    public float enginelift = 0.0075f;
    // Start is called before the first frame update
    void Start()
    {
    // Update is called once per frame
    void Update()
    {
        float throttleInput = Input.GetAxis("Throttle");
        if (throttleInput > 0)
        {
             enginepw += enginelift;
        }
        else
        {
             // Slow down the engine when throttle is not pressed
             enginepw -= enginelift * 0.5f; // You can adjust the rate of slowing
down here
              // Ensure engine power doesn't go below 0
              enginepw = Mathf.Max(0, enginepw);
          }
    }
}
using   System.Collections;
using   System.Collections.Generic;
using   System.Collections.Specialized;
using   System.Security.Cryptography;
using   System.Threading;
using   UnityEngine;
public class rotors : MonoBehaviour
{
    public enum Axis
    {
        X,
        Y,
        Z,
    }
    public Axis rotationAxis;
    private float bladespeed;
    public bool inverseRotate = false;
    private Vector3 rotation;
    private float rotateDegree;
    public float bladespd
    {
        get
        {
              return bladespeed;
        }
        set
        {
              bladespeed = Mathf.Clamp(value, 0, 2300);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        rotation = transform.localEulerAngles;
    }
    // Update is called once per frame
    void Update()
    {
        if (inverseRotate)
        {
             rotateDegree -= bladespeed * Time.deltaTime;
        }
        else
        {
             rotateDegree += bladespeed * Time.deltaTime;
        }
        rotateDegree = rotateDegree % 360;
        switch (rotationAxis)
        {
            default:
                transform.localRotation = Quaternion.Euler(rotateDegree,
rotation.y, rotation.z);
                break;
            case Axis.Y:
                transform.localRotation = Quaternion.Euler(rotation.x,
rotateDegree, rotation.z);
                break;
            case Axis.Z:
                transform.localRotation = Quaternion.Euler(rotation.x, rotation.y,
rotateDegree);
                break;
        }
    }
}