CREATE YOUR WORLD
User Interface

Use haptic vibration

4min

This guide will show you how to implement haptic vibration in ZEPETOScrip based on the Handheld.Vibrate function provided by Unity.



Write a script

1) In the [Project] panel, select the [+] menu in the upper-left corner or select Assets > Create > ZEPETO > TypeScript.

Document image




2) Name the added script HapticVibration, and write a sample script as shown below.

TypeScript




3) Add a GameObject to the Scene and rename it HapticFeedback. Add the HapticVibration ZEPETOScript you created. In the Hierachy window, drag & drop the Button UI to the Property shown in the ZEPETOScript Inspector window.

Document image




Testing on mobile

1) Run the example world with the QR mobile test.

2) When you press the button connected to the script, your device will vibrate.

📘 Please refer to the following guide. [QR mobile test]

❗️ Caution Please note that Handheld.Vibrate only works in the mobile environment.