Jumping Question

First…not sure if I’m asking this in the right place as I hit the ask button and it told me I was asking in the Default space. Second…I’m a noob to Unity just starting out. I’m making a top down strategy game ATM. The problem I am having is I need to have my character able to jump from platform to platform by clicking the platforms and have the script able to judge the distance to say weather it is too far or not. alt text

The ruler thing is maximum jump distance. Logs, Start, and rocks are platforms you can land on.

From START you can jump to any log or rock by clicking on it as its distance to everything is within maximum distance.
You can jump from 1 to 7 PAST start…or land on START if desired and vise-versa.
3 to 5 is too far so it wouldn’t let you. you would have to land on something else such as START.
7 to 3 and back is shorter than the max so you can do that as well.

How would I go about making it so it checks the distance from where the player is to what you clicked and use that info to prevent you from jumping too far?

Thanx in advance for even bothering to read this. =o)

Simply check the distance with Vector3.Distance, like this:

var player: Transform; // player reference
var maxDistance: float = 10.0;

function Update(){
  if (Input.GetButtonDown("Fire1")){
    var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    var hit: RaycastHit;
    if (Physics.Raycast(ray, hit)){ // if something clicked...
      // calculate the distance from player:
      var dist = Vector3.Distance(player.position, hit.transform.position);
      if (dist <= maxDistance){ // compare to the max distance
        // distance short enough - jump there
      } else {
        // distance too long - don't jump
      }
    }
  }
}