Collision detection glitch

Below is my script, I am trying to stay away from unity’s built in physics engine. For some reason, my player keeps falling through the floor when I start to move the play via the input keys (w,a,s,d, arrow keys) like in the pictures below.


// Declaration of Variables

void FixedUpdate(){

//Function to set gravityEnabled bool value
bool GravityEnabled(){

	RaycastHit hit;
	Vector3 playerDown = new Vector3 (transform.position.x, -1f, transform.position.z);

	if (Physics.Raycast(transform.position, playerDown, out hit)){

	return gravityEnabled;

void applyGravity(){
	//simply apply a downward force
	transform.position += (Vector3.down * Gravity * Time.deltaTime);

void MovementManager(){

	float X = Input.GetAxis("Horizontal") * horzontal_Movement * Time.deltaTime;
	float Y = Input.GetAxis("Vertical") * vertical_Movement * Time.deltaTime;
	bool applGForce = GravityEnabled();

	if (applGForce==true){
		transform.position += new Vector3 (X,0,Y);
	if (applGForce==false)		
		transform.position += new Vector3 (X,0,Y);

I know this is a lot, but I just want an insight as to possibly why this is happening?

Thank you in advance.

This has happened to me before and i always solve it by turning ridgidbody off. If it’s vital to your game that rigidbody is on then i dont know.