Skip to main content
Participant
August 16, 2016

How to detect if touchpad is being held

I want to have a game object keeps on moving around only when the touchpad is being held. The SingleTap only moves the game object when tap the touchpad. Then, I tried Input.GetMouseButtonDown(0). It doesn't seem working, either. How can I do that? 
This topic has been closed for replies.

2 replies

Inspiring
August 16, 2016
Try checking Input.mousePosition each frame. You could either compare the frame-to-frame differences or compare it to 0.
Participant
August 17, 2016
Hi, thank you for your respond! I tried comparing the previous frame's mousePosition and current frame's mousePosition, if they are the same, then the touchpad is being held, then I call a function to move my gameObject. But it doesn't keep on moving the gameObject while holding touchpad. It only moves when i tap it. 

Below is what I did but it only move when I tap it:
void Update() {




     if (Input.GetMouseButtonDown (0)) {  
               if  (Input.mousePosition == PreviousPosition) {
                          moveMyGameObject();
               }
     }
}

If I use the editor to run it with keep on pressing the space bar like below, then the gameObject keeps on moving as I want:





if (Input.GetKey (KeyCode.Space)) {

            moveMyGameObject ();
}
So this is what I want the gameObject do in VR.

Is that how what you mean by compare the frame-to-frame differences? Can you give me an example of frame-to-frame difference and compare it to 0? Thanks!