Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
ChristineZheng's avatar
ChristineZheng
Honored Guest
10 years ago

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? 

2 Replies

Replies have been turned off for this discussion
  • 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!