public var faceValue = 0;

public var idleTime = 1.0; // amount of time to sit idle before setting value

private var dieValueComponent; // cache the dieValueComponent

private var totalTimeTriggered = 0.0;

function Start() {
	dieGameObject = GameObject.Find("SixSidedDie");
	dieValueComponent = dieGameObject.GetComponent("DieValue");
}

// called when colliders first meet
function OnTriggerEnter( other : Collider ) {
	// make sure that totalTimeTriggered is zero
	totalTimeTriggered = 0.0;
	Debug.Log(faceValue + " entered " + other.name);
}

// called while colliders are touching
function OnTriggerStay( other : Collider ) {
  // add to total time
  totalTimeTriggered += Time.deltaTime;
  
  // only change the die value if die has been trigger for idleTime seconds
  if (totalTimeTriggered > idleTime) {
    dieValueComponent.currentValue = faceValue;
  }
}

// called when collider leaves 
function OnTriggerExit( other : Collider ) {
	// clear the total time
	totalTimeTriggered = 0.0;
}