• Touch Camera
  • How To find out If I am currently dragging my finger over screen

I have a scenario where the camera is following the target but as soon as I start dragging my finger over the map I need the camera to stop following the target, I specifically need to detect dragging so I can start panning over the map and then the object following stops. Can you help me how to do it?

Thank you

    larex changed the title to How To find out If I am currently dragging my finger over screen.

      larex Sorry for the late reply, I'm currently on vacation.

      There is no direct way to detect that the user is translating but you can achieve this using two things:

      • This method will tell you if the user has 2 fingers on the screen, or uses an input to drag according to the input map on your component. You will need to make that method public to access it from outside.
        IsInputMatching( InputMapFingerDrag.Translate )
        Keep in mind that this will return true also if you zoom with 2 fingers.

      • This will give you the center point on screen of all the fingers or pointers touching the screen. You can check if that points is moving over time to detect a translation:
        CameraInputs.screenPointAnyFingerCountCenter

      To Stop the object following you can call "StopFollow()" on any camera component.

        I did it with Finger down script where I plugged another script with method that compares position of finger with previous frame. If positions are not same that means I am dragging and then I will trigger Camera stop follow method.

        Write a Reply...