Search Unity

Issue with touch sensitivity

Discussion in 'iOS and tvOS' started by sean244, Dec 3, 2019.

  1. sean244

    sean244

    Joined:
    Nov 4, 2017
    Posts:
    95
    In my 2d shooter, if the user is playing on a desktop computer, they can click and drag the crosshairs with their mouse and the PointerClick eventhandler will execute the Fire() function once the left mouse button has been released. The bullet will then travel along a very specific direction:

    Code (CSharp):
    1. Vector2 dir = (Cam.GetMouseWorldPosition - firePoint).normalized;
    This works fine on computer. However, once I port my game to iOS, there's a problem: The user can drag with their finger and once the finger is released, the fire button will execute - however, the accuracy is off. The second they remove their finger, the pointer position has also been moved - which means that the bullet did not fire exactly where the user intended for it to fire.

    So I just need to know how to make it so that when the user releases their finger from the screen, the position of the pointer doesn't move. Does anyone know how I can do this?
     
    Last edited: Dec 3, 2019