Player falls through the floor upon movement (C#)

Hi, I have a playerphysics script which causes my player object to fall through the floor when I move it.

using UnityEngine;
using System.Collections;

public class PlayerPhysics : MonoBehaviour {

public float gravity = 20.0f;
private Vector3 moveDirection =;

void Start ()


void Update () 
	CharacterController controller = GetComponent<CharacterController>();
	moveDirection.y -= gravity * Time.deltaTime;
	controller.Move(moveDirection * Time.deltaTime);



It might be any of the following reasons:

  1. In your unity editor Check your character controller and
    make sure its collider is not too
    far down the floor which might cause
    your character to fall.

2.Check if you have bounding boxes enabled in your world because that would be a MAJOR factor.