Move object to specific coordinates

Hi i need a little help on raycast, if there anyone ill appreciate.

What i have so far and what ive want to do:

I have an Gameobject(myplayer) in a terrain with a camera to follow (myplayer), i have a script that allow me to select things and know what object are selected (raycast).

Now what im trying to do is, when my player are selected, i want to move it to a certain point on terrain with Input.Mousebutton, but i dont know how the best way to do this...

ive tried to create a simple test with

var hit : RaycastHit; var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);

*myplayer.trsansform.position = Vector3(Input.mousePosition.x,Input.mousePosition.y,Input.mousePosition.z);

but that doesnt work, myplayer disapears from screen and the y keeps increse.

so ive decided to ask if its a method with coordinates, that we can grab input.mouseposition when and where weve clicked, and myplayer to go to those coordinates?

Something like this:

var ray: coordinates

myplayer.transform.position = Vector3(ray.x,ray.y,ray.z);

...

Thank you

You could refer to below script, it shows how to move your object to a location when mouse clicked using Raycast.

http://www.unifycommunity.com/wiki/index.php?title=Click_To_Move

edit: Site was moved :

http://wiki.unity3d.com/index.php?title=Click_To_Move