How do you Change the Height of a Capsule Collider in C#?

I’ve been trying to work on a Crouching Mechanic for an FPS style game. I cannot seem change the height of my capsule collider to reflect this. Here is the control portion of my code. This is all in C#

using UnityEngine

using System.Collections;
[RequireComponent (typeof(CharacterController))]

public class FPSCtrlr : MonoBehaviour {
	public float CCStandHeight = 2.0f;
	public float CCCrouchHeight = 1.0f;
	bool crouch = false;
	CharacterController characterController;
	CapsuleCollider playerCollider;
	// Use this for initialization
	void Start () 
		Screen.lockCursor = true;
		characterController = GetComponent<CharacterController>();
		playerCollider = GetComponent <CapsuleCollider>();
	// Update is called once per frame
	void Update ()
		//Stand to Crouch
		if (Input.GetButtonDown ("Crouch") && crouch == false)
			playerCollider.height = CCCrouchHeight;			
			crouch = true;
		//Crouch to Stand
		if (Input.GetButtonDown ("Crouch") && crouch == true)
			playerCollider.height = CCStandHeight;			
			crouch = false;

All other portions of the code work fine so I only included the part giving me problems.

You don’t need a separate capsule collider on your object with Character Controller attached to it since Character Controller already has a capsule collider with it.

Remove your capsule collider component. And you can set the height of the capsule collider on the Character Controller using CharacterController.height.

Also to let you know in order to handle the collisions for Character Controller you need to use CharacterController.OnControllerColliderHit(ControllerColliderHit) and not OnCollisionEnter.