I’m working on a targeting system that evaluates every nearby enemy and determines who is the best target. I can get linear distance really easily with this:
float maximumRange = 15f; //maximum distance an enemy may be hit from
float distance = Vector3.Distance (attacker.transform.position, target.transform.position);
However, ideally what I need is to convert each distance to a value between 0-1, where an enemy standing on top of player (and thus matching his coordinates) receives a 1, and an enemy whose distance==maximumRange recieves a 0.1. Is there a simple way to compute this, or am I looking at a whole lot of legwork?