Hi, I´m trying to make a system in which I detect the color of a platform I hit, but it doesn’t seems to work, how can I detect var + renderer.material.color?
Code:
void FixedUpdate () {
if(touchingPlatform && renderer.material.color(210,2,2)){
transform.localPosition = startPosition;
}
}
I am pretty sure that statement is just going to set the color, not compare it. You might try something like this:
Color myColor = new Color(210f, 2f, 2f, 1f);
if(touchingPlatform && renderer.material.color == myColor){
transform.localPosition = startPosition;
}
The values of the Color variable are between 0 and 1, not 0 and 255 :
Each color component is a floating point value with a range from 0 to 1
Apart form that, greenshadow is correct, you want to check if your renderer is equal to somthing :
if ( touchingPlatform && renderer.material.color == Color(210,2,2) ) {