Character Controller Falls Through Floor

I'm fairly new to unity 3d and ive been trying to get used to scripting. I've found some scripts that apply gravity to a character controller and allow them to collide with objects but I dont understand how they work. I tried to make a script that did that and I ot the gravity part but now it just falls through the floor. Here's the script I used:

var gravity = 10;

var speed = 0.1; var rotspd = 2.0;

function Update () { var controller : CharacterController = GetComponent(CharacterController);

//Apply gravity
controller.transform.Translate(0, -gravity * Time.deltaTime, 0);

controller.transform.Translate(0, 0, Input.GetAxis("Vertical") * speed);
controller.transform.Rotate(0, Input.GetAxis("Horizontal") * rotspd, 0);

@script RequireComponent(CharacterController)

How do I make the controller collide with other objects?

You don't need to use a script for this. You need to make sure you have a rigid body component (Component>Physics>Rigidbody) and then make sure "Use Gravity" is ticked.

You can then use a collider (best ot use a box collider and resize it to the size of your character) to automatically collide with objects.

If you're new to Unity I would reccommend reading some tutorials and the manual located here:

Start off simple. Make Pong. It requires collision, player input, scores, and you can add a GUI. Then move onto more and more advance stuff.

I’ve seen this when I add a character (like the soldier from the Locomotion demo) who is 100 times too big. So you set scale to .01 to make it look right. But now the character controller is 100 times too small. So set its height to like 200 and radius to 50