c# - Trying to refine several if statements down -
i'm trying find more elegant way reduce if statements down, have right little messy , reckon done better, suggestions? if(ship.position.y >= transform.position.y + ybound) { hitbounds = true; } if(ship.position.y <= transform.position.y - ybound) { hitbounds = true; } if(ship.position.x >= transform.position.x + xbound) { hitbounds = true; } if(ship.position.x <= transform.position.x - xbound) { hitbounds = true; } thanks time! update if(mathf.abs(ship.position.x - transform.position.x) >= xbound || mathf.abs(ship.position.y - transform.position.y) >= ybound) { hitbounds = true; } worked treat, million! hitbounds = math.abs(ship.position.x - transform.position.x) >= xbound || math.abs(ship.position.y - transform.position.y) >= ybound;