I’m pretty sure my math is just broken but Im basically trying to set the alpha of something relative to the player’s Y position.
Im using this math to set the alpha:
if (PlayerConditions.playerY < 290){
GUI.color.a = 1 - ((PlayerConditions.playerY - 170) / 120);
Debug.Log(1 - ((PlayerConditions.playerY - 170) / 120));
}
else{
GUI.color.a = 0;
}
The debug log is returning 1 which means the object has 100% opacity which is obviously not what I want.
What’s wrong with my math here?
In case you’re wondering 170 is the height of my death floor which kills the player. 290 is where I want the object to start becoming visible.