My Door Opening Script Works Inconsistently

I have created two scripts which control my doors opening and closing (Thanks to people who helped me here! So thanks guys!. However my scripts do not seem to work all the time. I have to push the doors many times till I hit their sweetspot or something. It’s very important that my doors are user friendly! Perhaps something is wrong with my scripts? I’d appreciate it if you guys could have a look to see where I went wrong if you have time!

This is the Player Collision script (Attached to my character controller main camera):

private var currentDoor : GameObject;

function Update () {

	var hit : RaycastHit;

	    if(Physics.Raycast(transform.position, transform.forward, hit, 2)) {
		if(hit.collider.gameObject.tag == "Door"){
		currentDoor = hit.collider.gameObject;
		currentDoor.GetComponent(DoorScript).OpenCheck ();

And here is my actual door script (Attached to each door in my scene)

var doorIsOpen : boolean = false;

var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;

function OpenCheck (){

if(doorIsOpen == false){
Door(doorOpenSound, "doorOpen");
doorIsOpen = true;


else if(doorIsOpen == true){
Door(doorShutSound, "doorClose");
doorIsOpen = false;


function Door (aClip : AudioClip, animName : String) {


The script does work, but it requires that I click over and over which is frustrating

I thought it might be the order of operations, but I changed things around as best I could to make them operate in the right order, but still the same issue occurs.
I ran a debug on the raycast to see if it wasn’t picking up the door fast enough. From this I discovered that you have to click as soon as the raycast hits the door (the raycast hits every frame I believe). So the player has to hit the door as soon as the frame changes. Is there any way around this?

Ok so as it turns out it was simply the size of my character controller and nothing else that made it work inconsistently
Odd, but solved!

Ok it wasn’t the size at all. I6 was because I had a rigidbody on my char controller