Help with RaycastHit

Im using RaycastHit to detect if I’m looking at any objects, and if I am, I can teleport onto them.

However at the minute it teleports onto the middle of the object, but I want it to teleport to whereever on the object was clicked. How would I do that?

This is what I have so far.

var hit: RaycastHit;
    if(Physics.Raycast(Gun.transform.position, Gun.transform.forward, hit)){
    	if(hit.transform.tag == 'JumpTo'){
            Text.guiTexture.enabled = true;
           
            if(Input.GetButtonDown("Fire1")){
                var distance = Vector3.Distance(Player.transform.position,hit.transform.position);
                   
                if(distance < 17)
                    Player.transform.position = Vector3.Lerp(Player.transform.position,hit.transform.position+(Vector3.up*5), Time.time);
                    
            }
        }
        else
            Text.guiTexture.enabled = false;
	}

use a MeshCollider instead. then you have access to all the nice members of your RaycastHit, like point, textureCoord etc.

be aware collisions with MeshColliders take longer to calculate!

Thats great thanks :).

Changed line 10 to

Player.transform.position = Vector3.Lerp(Player.transform.position,hit.point+(Vector3.up*5), Time.time);

and it works like a treat.