/
darov
/
CrazyRun
Обзор
Документация
Войти
/
darov
/
CrazyRun
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Assets/Scripts/CustomTouchInput.cs
67 строк
2 KB
Roman Danilov
touch_input
27 янв 2026, 10:08
27 янв 2026, 10:08
18865f9
Код
Авторство
О чём код?
using UnityEngine; public class CustomTouchInput : MonoBehaviour { [SerializeField] private Rigidbody _rigidbody; [SerializeField] private float _speed; private Vector3 _force; private float _touchTime; private bool _isTouchEnded = true; private void Update() { if (Input.touchCount > 0 && Input.touchCount < 2) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Stationary && _isTouchEnded) { _touchTime += Time.deltaTime; if (_touchTime > 2f) { Debug.Log("������� ��c���� ��������!"); _isTouchEnded = false; } } if (touch.phase == TouchPhase.Ended) { if (_touchTime < 1f) { Debug.Log("���!"); } _touchTime = 0f; _isTouchEnded = true; } //if (touch.phase == TouchPhase.Began) //{ // _isTap = true; //} //_force = new(touch.position.x, 0f, touch.position.y); //_rigidbody.AddForce(_force * _speed); if (touch.deltaPosition.x > 0) { Debug.Log("�������"); } if (touch.deltaPosition.x < 0) { Debug.Log("������"); } } if (Input.touchCount > 1) { for (int i = 0; i < Input.touchCount; i++) { Debug.Log("������� �" + i + " c �������� " + Input.touches[i].position); } } } }