Forum Discussion
ChristineZheng
10 years agoHonored Guest
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
- vrdavebOculus StaffTry checking Input.mousePosition each frame. You could either compare the frame-to-frame differences or compare it to 0.
- ChristineZhengHonored GuestHi, 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!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 2 years agoAnonymous
- 3 months ago