Quantcast
Viewing latest article 4
Browse Latest Browse All 154

hold touch to move, tap to rotate

public float holdTime = 4f; void Update() { Move(); } public void Move() { if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Stationary) { float startTime = Time.time; if (startTime >= holdTime) { Vector2 touchPosition = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); transform.position = Vector2.Lerp(transform.position, touchPosition, Time.deltaTime); } } } I need to if touch hold 2 seconds character moved to the touch spot and if just one tap turned towards to spot

Viewing latest article 4
Browse Latest Browse All 154

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>