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
↧