var newpoint:Vector3;
static var xover:boolean=false;
function Start (){
newpoint=Vector3.zero;
}
function Update () {
print(transform.rotation);
if(Input.GetKey(KeyCode.Mouse0)){
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
newpoint=hit.point;
xover=true;
}
}
if(xover==true){
var newpointRotation=Quaternion.LookRotation(newpoint-transform.position,Vector3.up);
transform.rotation=Quaternion.Slerp(transform.rotation,newpointRotation,Time.deltaTime*10.0);
var targetDir =newpoint-transform.position;
var forward = transform.forward;
var angle = Vector3.Angle(forward,targetDir);
if(angle <5){
xover=false;
}
}
}