I’m trying to make it so that if my player (a ball) rolls over a cube of a different color than the ball it falls through. I thought I’d be able to do this simply by checking if the color of the ball was equal to the color of the cube, but this doesn’t seem to be working.
This script is applied to the cube:
#pragma strict
var color:Color=Color.blue;
gameObject.renderer.material.color=color;
function OnTriggerEnter(bink:Collider){
if ((bink.tag=="Player")&&(bink.renderer.material.color != color)){
Disappear(5);
}
}
function Disappear (runTime : float) {
var timer = 0.0;
while (timer < runTime) {
gameObject.collider.enabled = false;
timer += Time.deltaTime;
yield;
}
gameObject.collider.enabled = true;
}