It makes me more touch delay because of this. So help me how to reduce touch delay? If time.deltatime is working then where can i put it?
if (Application.isMobilePlatform)
{
if (Input.touchCount > 0)
{
for (int t = 0; t < Input.touchCount; t++)
{
Touch touch = Input.GetTouch(t);
TouchPhase phase = touch.phase;
if (phase == TouchPhase.Began)
{
aimTouchPosition = Camera.main.ScreenToWorldPoint(touch.position);
Shoot(aimTouchPosition);
}
}
}
}
}
public void Shoot(Vector3 aimPosition)
{
RaycastHit2D raycastHit2D = Physics2D.Raycast(aimPosition, Vector2.zero);
if (raycastHit2D.collider != null)
{
if (raycastHit2D.collider.tag == "Enemy")
{
raycastHit2D.collider.gameObject.GetComponent<CSGTEnemy>().hit();
}
}
}