Character Controller Collision

My character isn’t colliding with objects head on he just walks right through them. If he jumps and lands on them the collision works great he can sit on top of any cube I create it’s just when he hits them head on walking forward or backward. The only thing I can think of is how I am moving the controller maybe? Code and controller settings below, any ideas?

Character Controller Settings: Slope Limit = 45, Step Offset = .3, Skin Width = .08, Min Move Distance = 0

var walkSpeed : float = 5.0;
var jump : float = 5.0;
var gravity : float = 9.8;
var player : GameObject;
var runSpeed : float = 8.0;

private var jumpNumber : int = 0;
private var moveDirection = Vector3.zero;
private var speed : float = 5.0;



function Update () 

{
    var controller : CharacterController = GetComponent(CharacterController);
    
	      
    // Adds Gravity
    moveDirection.y -= gravity * Time.deltaTime;
 
	
	
	// Move the controller
	controller.Move(moveDirection * Time.deltaTime);

	
	//Walk Right
	if(Input.GetButton("MoveRight"))
	{
	
		//animation["Walk"].speed = 1.5;
		transform.Translate(Vector3.right * Time.deltaTime * speed);
		
	
	}
	
	
	//Walk Left
	if(Input.GetButton("MoveLeft"))
	{
	
		transform.Translate(Vector3.left * Time.deltaTime * speed);
		
	}
	
	
	//Double Jump
	if(controller.isGrounded)
	{
		jumpNumber = 0;	
	}
	
	
	if(Input.GetButtonDown("Jump") && jumpNumber < 2)
	{
	
		
		moveDirection.y= jump;
		jumpNumber ++;
	
	}
	
	
	//Reset on Death
	if(player.transform.position.y <= -20)
	{
	
	Application.LoadLevel("Squish");
	
	
	}
	
	//Sprint Function
	if(Input.GetButtonDown("Run") && controller.isGrounded)
	{
	
		speed = runSpeed;
	
	
	}
	
	//Sprint Function Release
	if(Input.GetButtonUp("Run"))
	{
	
		speed = walkSpeed;
	
	
	}
	

	
	
}

i know that you need to put a mesh collider on components

Try it with a first person character controller (Assets > Import Package > Character Controllers). Are your using the character controller movement script?

If that does not work it a problem with the cube.

If it works it a problem with the collider.

If its a problem with the collider, what I recommend is to change the character controller to the shape you want and retexture it (make it your previous charater). I also see your controllers collider has an unnatural shape, change that to fit the character more securely, it may be conflicting with the cubes box.

If its a problem with the cube, try changing the material and adding a different cube higher above the floor. Also, make sure no scripts are referencing it.

Good luck!

I figured out that if I changed

 //Walk Right
if(Input.GetButton("MoveRight"))
{
 
//animation["Walk"].speed = 1.5;
transform.Translate(Vector3.right * Time.deltaTime * speed);
 
 
}
 
 
//Walk Left
if(Input.GetButton("MoveLeft"))
{
 
transform.Translate(Vector3.left * Time.deltaTime * speed);
 
}

To this

 //Walk Right
if(Input.GetButtonDown("MoveRight"))
{
 
moveDirection.x = speed;
 
 
}
 
 
//Walk Left
if(Input.GetButtonDown("MoveLeft"))
{
 
moveDirection.x = -speed;
 
}

The collision works perfectly fine. So it was the way I was moving my character around that caused it.

You should use this: Unity - Scripting API: CharacterController.Move