Touch velocity detection for Unity using an accelerometer. Inspired by GarageBand for iOS.
Read this in other languages: English, ํ๊ตญ์ด.
No dependencies other than Unity are required. Let me know if anything happens!
- Create an empty GameObject and name it PressureTouchGestureRecognizer.
- Download the PressureTouchGestureRecognizer.cs script and add it to the GameObject.
- When triggered, "pressure" is set to a float between 0.0f and 2.0f.
- Optionally, you can set the minimum and maximum touch sensitivity required for recognition.
private PressureTouchGestureRecognizer recognizer;
void Start()
{
recognizer = GetComponent<PressureTouchGestureRecognizer>();
recognizer.SetAction(HandlePressureTouch);
}
void HandlePressureTouch(float pressure)
{
Debug.Log("pressure = " + pressure);
}