void LateUpdate()
{
if (!_canMove) return;
_tap = false;
_canMove = false;
// if (!Input.GetMouseButtonUp(0)) return;
var ts = Input.touches;
// Debug.Log ("touches " + EventSystem.current.IsPointerOverGameObject());
if (ts.Length > 1 || (ts.Length > 0 && EventSystem.current.IsPointerOverGameObject(ts[0].fingerId))
|| EventSystem.current.IsPointerOverGameObject()) return;
// Find all object in ray, and sort them by distance to object.
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hits = Physics.RaycastAll(ray, 100);
hits = hits.OrderBy(h => h.distance).ToArray();
var state = hits.Select(hit => GameObjectToState(hit.transform.gameObject, hit))
.FirstOrDefault(s => s != null);
if (state != null)
_ai.AssignNewState(state);
}