![alt text][1]
Hi,i am trying to make my GreenSphere to teleport or move to the position where i clicked on,but theres aways got error can some1 help me check my script??
as now when i click will display the position coordinates,so i want the ball to move to the coordinates.Thx
private var hitPos : Vector3 ;
private var hitObjectPos : Vector3 ;
private var hit : RaycastHit ;
private var Down : boolean = false;
function Start(){
GameObject.Find("Sphere11").renderer.enabled = false;
}
function Update(){
if(Input.GetMouseButtonDown(0)){
Down = Input.GetMouseButtonDown(0);
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition) ;
GameObject.Find("Sphere11").renderer.enabled = true;
if(Physics.Raycast(ray , hit)){
hitPos = hit.point ;
hitObjectPos = hit.transform.position ;
}
}
GameObject.Find(“Sphere11”).transform.position = new Vector3(hitPos.transform.position.x , 5 , hitPos.transform.position.z); //think this part got error?/
}
function OnGUI(){
//The world position of the ray’s contact point->
if(Down == true){
GUI.Label(Rect(5,50,200,50),hitPos+ "") ;
}
}