Это отлично работает в редакторе, но когда я создал APK и играл на своем телефоне, он телепортируется из последней точки. Итак, если я переместимся в верхний левый угол, поднимем палец и поместим его в правый нижний угол, вы увидите тонкую и быструю диагональную линию.
Вот мой код:
Код: Выделить всё
private void Update()
{
if (Event.current == null || (Event.current != null && EventSystem.current.currentSelectedGameObject == null))
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
circleCollider.enabled = false;
currentTrail = Instantiate(trail, transform);
isCutting = true;
}
else if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
circleCollider.enabled = false;
currentTrail.transform.SetParent(null);
Destroy(currentTrail, 2f);
isCutting = false;
}
}
if (isCutting)
{
Vector2 newPos = currentTrail.transform.position = rb.position = cam.ScreenToWorldPoint(Input.mousePosition);
float velocity = (newPos - previousPos).magnitude * Time.deltaTime;
if (velocity > minCuttingVelocity)
{
circleCollider.enabled = true;
canCut = true;
} else {
circleCollider.enabled = false;
canCut = false;
}
previousPos = newPos;
}
}
Подробнее здесь: https://stackoverflow.com/questions/510 ... eleporting
Мобильная версия