var GO:GameObject;
static var pointx:float;
static var pointy:float;
static var pointz:float;
function Start (){
pointx=GO.transform.position.x;
pointy=GO.transform.position.y;
pointz=GO.transform.position.z;
}
function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
Debug.DrawLine (ray.origin, hit.point);
print(Mathf.Round(hit.point[0]));
}
if(Input.GetKey(KeyCode.Mouse0)){
pointx=hit.point[0];
pointy=hit.point[1];
pointz=hit.point[2];
/*
if(pointy-GO.transform.position.y>0){
GO.transform.position.y+=2*Time.deltaTime;
}
else if(pointy-GO.transform.position.y<0){
GO.transform.position.y+=-2*Time.deltaTime;
}
*/
// print(Mathf.Round(pointx));
//GO.transform.position.x=pointx;
//GO.transform.position.y=pointy;
//GO.transform.position.z=pointz;
}
if(Mathf.Round(pointx-GO.transform.position.x)>0){
GO.transform.position.x+=2*Time.deltaTime;
}
else if(Mathf.Round(pointx-GO.transform.position.x)<0){
GO.transform.position.x+=-2*Time.deltaTime;
}
if(Mathf.Round(pointz-GO.transform.position.z)>0){
GO.transform.position.z+=2*Time.deltaTime;
}
else if(Mathf.Round(pointz-GO.transform.position.z)<0){
GO.transform.position.z+=-2*Time.deltaTime;
}
}