en:vci:sample:onuse:hapticitem

Vibrate a controller on grip button press

This VCI vibrates a controller when a grip button is pressed.

Example data

Material data

You don't need any material to create a vibrating VCI.
Prepare a 3D model based on what you want to create with VCI.

Component setting

You can easily check this by creating a grabbable SubItem.
Also, set the component as shown below for easy handling.


  • Collider…Enable IsTrigger
  • Rigidbody…Enable IsKinematic, disable UseGravity
  • SubItem…Enable Grabbable

Script

main.lua
function onUse(use)
    -- use stores the name of grabbed SubItem
    vci.assets.HapticPulseOnGrabbingController(use, 3000, 1)
    print("Vibrate a controller which used"..use)
end

VCI Script (Description)

The argument “use” in onUse(use) contains the name of the used SubItem as a string.
By using the “use” as the argument on the vci.assets.HapticPulseOnGrabbingController(use, 3000, 1), you can vibrate a controller with any objects when used.
The second argument specifies the strength of vibration (0~3999); the third argument specifies the length of the vibration. HapticPulseOnGrabbingController

If you want the vibration to occur with a specific SubItem only, you need to separate the process with “if” statement depending on the used SubItem.

en/vci/sample/onuse/hapticitem.txt · Last modified: 2023/10/04 18:07 by pastatto

Page Tools