Translations of this page:

Sidebar

en:vci:sample:onuse:no2

Rumble a controller on grip button press


This article was written for “UniVCI-0.15.”

Example data:https://seed.online/items/aaba774f7ad1f2008caf4b934638def9064309fbe3a0ff4638c46dbc66497153

To execute a process when the grip button is pressed, use “onUse”.

In this example, we will create a process that rumbles a controller
when the grip button is pressed against a certain “VCI SubItem”.

1. Create a new GameObject and create a Cube as its child.

In this example, we named the GameObject “Vibration_VCI,” but it can be anything really.
Let's name the Cube “Cube.”
Specify Y-axis value of the Cube to 1 so that it doesn't go through the floor.

2. Attach a “VCI Object” component on the GameObject,
and attach the “VCI SubItem” component on the Cube.
When doing this, “RigidBody” components are also attached automatically.
As the Cube won't be using gravity, turn off Use Gravity and turn on Is Kinematic.

3. On the VCI Object component in the GameObject, set the Scripts Size as 1.
Enter “main.lua” in the Name and paste the script shown below.

main.lua
local Cube = vci.assets.GetTransform("Cube")
 
function onUse(use)
    if use == "Cube" then
        vci.assets.HapticPulseOnGrabbingController(use, 3000, 0.1)    --Rumble the controller
    end
end
en/vci/sample/onuse/no2.txt · Last modified: 2022/03/06 23:11 by Ramen

Page Tools